From nobody Wed Jun 29 07:39:05 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 519A387D1BA; Wed, 29 Jun 2022 07:39:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LXtd56C68z4WhN; Wed, 29 Jun 2022 07:39:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656488345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Cr7AHPZ/9eYyWiZhlEAWtR0AqnZI1H1jh/D/AjJck9c=; b=UY1931ICBdoWc8X9RTj0y7AYwBLw35/kiAF2lPkN9yNiwYg53c6UNvYCLXCp6R5vw4GOft 5HCBZwGnOW/6iv68rBkShy7TigHZTLdV22YHP4Xf5VIpbIRL3CSLlOrtWZdufacQYhpg7q Td/KQVhxfZnsImkw2Ew7DgYb1hOpVp0/otDccB27SuRQxfSSgjtidr5nC2ANU5PaSelha+ nHdFgeJem7E0j2PxMVE7XEAlxFOwn/5ko36sKixGEpmWg/eQ6BvBi05QQzsvp1SvrsAiyW NJNCr9IM0/W2fsSGxGMqNX+0vFaALw/w8KyhwUN4Gn7BLEPI2gBZ3AqpWyf8jg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B4AF4580F; Wed, 29 Jun 2022 07:39:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25T7d5k7049777; Wed, 29 Jun 2022 07:39:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25T7d5HM049776; Wed, 29 Jun 2022 07:39:05 GMT (envelope-from git) Date: Wed, 29 Jun 2022 07:39:05 GMT Message-Id: <202206290739.25T7d5HM049776@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: 050f5a8405c6 - main - amd64: Reload CPU ext features after resume or cr4 changes List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 050f5a8405c63dadaf522d27c3d4f2a2ae522bf6 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656488345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Cr7AHPZ/9eYyWiZhlEAWtR0AqnZI1H1jh/D/AjJck9c=; b=MxTlMzsPrYEAClOMppHjja5qxz6xCQSmO4+YhcOyGgUZfYzXH+naCI7l+VBfH32wSpEHoh GadZGXBaNvygfjYaawUNaNXVWWwFQw49uCk7FyUEv1+KdlZQHUTFUqKlx902mSgYJAIM0V pyDgds4NuSjn1NMkVK1P2oJgwY4tQQqr6oaFU7kNED7oQ7z//Sv439T2YdscpqbgbLINVW i8hpy13WH8xCG1K9i09G8TR6aqI42LMgeHly8kRZCrjaj/FNJAX7L5idkt8V3FU52BcrcA qTVqkojxkJ2IcB2OEJfUrlJGHWec5f3XZiLI3VdNvc6B5yAePZlHkHEhgaOMZg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656488345; a=rsa-sha256; cv=none; b=XoQCU3KHjxyiAPSzM3MnQzeyAPc9nIYHrRG4Az8tH2EUA0ZfcGKlbvzfs0mUUztxWGVcr6 kU5L6Y73xeFUwf6WMLsiyayfPgQP6MSzeRBAEwEdCcQVuhOO+ODWs1lOQtm5ACNHsF3Nga Fn2Tl8uxlTqsneIxyuzjR567DUg+bf70xGVex7TyQ8BJEBUa5Jk8VNRDsfRXJ0EIf1Tfjk VK9qU8ImrYwuLw9Rc4g1La3yQw3dlcKcKE/h0w3ORPc4I3M8R2y6CZauePu4ovJnF5yX7y PoTm6SV9LiRb3j/vOnAmKa7q6VIpzvHYtbGuyB9ktOTHEIB8KfUD2KBKodtydg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=050f5a8405c63dadaf522d27c3d4f2a2ae522bf6 commit 050f5a8405c63dadaf522d27c3d4f2a2ae522bf6 Author: Dmitry Chagin AuthorDate: 2022-06-29 07:34:43 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-29 07:34:43 +0000 amd64: Reload CPU ext features after resume or cr4 changes Reviewed by: kib Differential revision: https://reviews.freebsd.org/D35555 MFC after: 2 weeks --- sys/amd64/amd64/initcpu.c | 3 +++ sys/x86/include/x86_var.h | 1 + sys/x86/x86/identcpu.c | 12 ++++++++++++ 3 files changed, 16 insertions(+) diff --git a/sys/amd64/amd64/initcpu.c b/sys/amd64/amd64/initcpu.c index 44a294da205a..1a251208cfd6 100644 --- a/sys/amd64/amd64/initcpu.c +++ b/sys/amd64/amd64/initcpu.c @@ -292,6 +292,9 @@ initializecpu(void) cr4 |= CR4_SMAP; } load_cr4(cr4); + /* Reload cpu ext features to reflect cr4 changes */ + if (IS_BSP()) + identify_cpu_ext_features(); if (IS_BSP() && (amd_feature & AMDID_NX) != 0) { msr = rdmsr(MSR_EFER) | EFER_NXE; wrmsr(MSR_EFER, msr); diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h index b4a27ca01eaa..3e8e643e1b9c 100644 --- a/sys/x86/include/x86_var.h +++ b/sys/x86/include/x86_var.h @@ -128,6 +128,7 @@ void restore_wp(bool old_wp); void finishidentcpu(void); void identify_cpu1(void); void identify_cpu2(void); +void identify_cpu_ext_features(void); void identify_cpu_fixup_bsp(void); void identify_hypervisor(void); void initializecpu(void); diff --git a/sys/x86/x86/identcpu.c b/sys/x86/x86/identcpu.c index 4ccbd3da311f..7b2d32d9c7a3 100644 --- a/sys/x86/x86/identcpu.c +++ b/sys/x86/x86/identcpu.c @@ -1608,6 +1608,18 @@ identify_cpu2(void) } } +void +identify_cpu_ext_features(void) +{ + u_int regs[4]; + + if (cpu_high >= 7) { + cpuid_count(7, 0, regs); + cpu_stdext_feature2 = regs[2]; + cpu_stdext_feature3 = regs[3]; + } +} + void identify_cpu_fixup_bsp(void) {