From nobody Tue Mar 21 13:23:16 2023 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 4Pgsjx1pYvz40JZv; Tue, 21 Mar 2023 13:23:17 +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 4Pgsjx1L9Sz4NZD; Tue, 21 Mar 2023 13:23:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679404997; 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=48Vr8Bk3lpDG2jPa3NwEAcTqbPK75470ASvUXg0zkHU=; b=SY9M2OWaZWHw81goGiAcccr19fYiXDe3NUR/P2mYRBslM2lkxg+pYANgN4y4OYmz3iJYa/ tI6EaLtWIpUnL627xPgr2PhqA41cZ0OrLRH/i0mgz5oZv+Icauy1KG14DwM31hyRzQLcEz /UD+3t54pJbitcWyxfQC5gRn9yWn/e5ctZ87IotEAuglj574qucL/5Xwv579DsHQCTQE2F 82wivdTdThBSS8FL4c+g3BylhLPmQw2i3ThM7gEspFkIhTrk9uA4YXrkWV7z1wPpPZnrUu o4S0Qk4R1/QT1urbLeuEiX5G9lM+3jpar4aQI/SvTEXdIJbPbs4mjjwuKCwwpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679404997; 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=48Vr8Bk3lpDG2jPa3NwEAcTqbPK75470ASvUXg0zkHU=; b=NJU2BTLNre9Vk9aKcURQF36RlrBGt9BBq2jNZmxRuAKBqsKoLcJEOr1dIDukHb0u1dZ820 1rsAELrmFrJc8RDgwO3kWyV5c8SqMDs+LyBBKUOCWkm2H6C55HOMMuZUS147K4T4mPPYBi qA7wE2M3tLYK3HM5jMHoEqxEYTe6UPsqcrwDtLaKAg0QS1Pg8Yl3X54AS+BfNhqTTUE2LL 4AXtuvUjtcX146+jFgYHpyoFKnjYie6nejwY/g4yjOp/iIXlK7mRHqbXUIqv2QUGL8rENo UErE93kBDBFjprIf3byWM0Y33AzE9mxcPShGMa5/ENxGr2JI/ECib+X6Wn4f+A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679404997; a=rsa-sha256; cv=none; b=iSr16y56QUvDj3JEqfSqaE9qq8wcz5QbTIvxHU4NlxvPkSn2j1SHDC+6zzAL55wztkrjRt Ohfhq7uOlzt8jWpk0pexxfq3gcW5bDO9phHbCxkqqXugH18k60zrFv3mscdinFtvK3j4I+ dSkDNo4Hxs5K6xFuiBLbdVTxl0pNSmSqvnpDYciuRCc3JIW6hlG2IOHWFc373NN8gXQ2zn wWf3J8cUIheivKomOCbUAovtl8edKQPJy9pZuc+y0Li9BnKVJw3+GJO6XTAc/1UEoUh/d4 LigxuLik3Odbbrs+J4Nyalx3UzIerIqG7FZ38QpFO6os28JWcCdf1DfJ0k7fUA== 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 4Pgsjx032vz1CWB; Tue, 21 Mar 2023 13:23:17 +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 32LDNG9x027793; Tue, 21 Mar 2023 13:23:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32LDNGmb027790; Tue, 21 Mar 2023 13:23:16 GMT (envelope-from git) Date: Tue, 21 Mar 2023 13:23:16 GMT Message-Id: <202303211323.32LDNGmb027790@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 7622d3671cbe - releng/13.2 - amd64: properly recalculate mitigations knobs after resume 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/releng/13.2 X-Git-Reftype: branch X-Git-Commit: 7622d3671cbef860d5dede0e4beace8fd152cd87 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch releng/13.2 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7622d3671cbef860d5dede0e4beace8fd152cd87 commit 7622d3671cbef860d5dede0e4beace8fd152cd87 Author: Konstantin Belousov AuthorDate: 2023-03-17 13:02:03 +0000 Commit: Konstantin Belousov CommitDate: 2023-03-20 18:13:02 +0000 amd64: properly recalculate mitigations knobs after resume Approved by: re (gjb) (cherry picked from commit 02904a06c76be857307b78184863654b9e7b88ab) (cherry picked from commit 7c5d3ec4c02b89754ec3ce55d1b7943c404209df) --- sys/amd64/acpica/acpi_wakeup.c | 14 ++++++++++++++ sys/amd64/amd64/initcpu.c | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sys/amd64/acpica/acpi_wakeup.c b/sys/amd64/acpica/acpi_wakeup.c index 9601a88e11a4..1afbdc3a3bec 100644 --- a/sys/amd64/acpica/acpi_wakeup.c +++ b/sys/amd64/acpica/acpi_wakeup.c @@ -288,6 +288,20 @@ acpi_wakeup_machdep(struct acpi_softc *sc, int state, int sleep_result, if (!CPU_EMPTY(&suspcpus)) resume_cpus(suspcpus); #endif + + /* + * Re-read cpu_stdext_feature3, which was zeroed-out + * in acpi_sleep_machdep, after the microcode was + * reloaded. Then recalculate the active mitigations + * knobs that depend on the microcode and + * cpu_stdext_feature3. + */ + identify_cpu_ext_features(); + hw_ibrs_recalculate(true); + hw_ssb_recalculate(true); + amd64_syscall_ret_flush_l1d_recalc(); + x86_rngds_mitg_recalculate(true); + mca_resume(); if (vmm_resume_p != NULL) vmm_resume_p(); diff --git a/sys/amd64/amd64/initcpu.c b/sys/amd64/amd64/initcpu.c index 16780a9e069b..8d4c9d9cbe64 100644 --- a/sys/amd64/amd64/initcpu.c +++ b/sys/amd64/amd64/initcpu.c @@ -313,7 +313,7 @@ initializecpu(void) } load_cr4(cr4); /* Reload cpu ext features to reflect cr4 changes */ - if (IS_BSP()) + if (IS_BSP() && cold) identify_cpu_ext_features(); if (IS_BSP() && (amd_feature & AMDID_NX) != 0) { msr = rdmsr(MSR_EFER) | EFER_NXE;