From nobody Mon Mar 20 07:14:11 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 4Pg5ZW66qLz40L9h; Mon, 20 Mar 2023 07:14:11 +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 4Pg5ZW5bghz42jM; Mon, 20 Mar 2023 07:14:11 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679296451; 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=/HVRmHniK7n0S9ze5x2A3GV8+KiAqgpFCsAYnZwmb4M=; b=ylAV6aPwef26ekjYt93bEoTL0bXJKgcEIweUg5g6axC4/H9vvTZP3StRcoqJ9bwba5I/ar sx6tXoQCncIGHlp3J8h6T/NTwTZlKrGMqw4HPd4RoLPTZ9qyiEmIX9siB/BqsgDwvPigor 1ij1b0kKYl1JRYdaRqOfiaxSubpyww8/LmL94vCIwlXLXjqP8mWSLx+kNjv3JGbrsMdcuD d0rnzSZ2VwH2glbLqpj0uWozw0SM9eQ/yzVSpy4CLsgY4rfnsRhIKOk9VPxj/L002+H59J +CmkZyuI9VHZAxCXqtYJ7jIi+gt574Q9QmqjZQ0QIJscOMrPLqjdwEfYI+LrWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679296451; 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=/HVRmHniK7n0S9ze5x2A3GV8+KiAqgpFCsAYnZwmb4M=; b=tJyLWjbHHpiboarvNGQ3GQ/XuWvtFu9Y7jEjSgDZMnXlZsF1OKzSe097R16GXVtqW9Fcyh 9z1KbNwpqAjSXNuoLRJzxx40YvRFPvBmZg2hUMWcKmBj7Nzp5XJvSCzU8iUivwnTwyGdYI S9WK/fMYTd/ryLGA46NKaFyPBYUwuaDgSye4pea2no9hzZZD6Z7FoCoXTpfT3M9rB13SSB wHsN7fuksafezJ+x/ULsR091Br5OE4KbQeOoJe8MJsUl1RrNVjSDia6fH69Wemjggin22O PVYVl4nwgL3l6AxkuCRTO3L+NevPYQHpc903b5JX2axS1Kq0U+V0SZhMgHZ25g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679296451; a=rsa-sha256; cv=none; b=PCL6G+uNtOq8BQak4OLIDfqBhkG19G3Nrb681m5oHgP8+yubnv5d3fWYojVgu5ejJNt+kI jFFakFSbE2PczTttIZASQIxxhCk+r4rjRKgaebS3QoDti9DmEvFD7dHP8uhwZjWcCUCJAc UxVQtqRvWARQ0sYZanJn5B5RhHA8uz4uuIPMO+B8PD8JRfQT6v7b5UlIVfylI9GFk2R1HT LFV467hsbzwmEjtStcuXgnSi5Mgf0u6fSw9x9oaamOeE/GzTlTQHlzC2AS4MnzjhRABZnC 3f/EB0GPKZFSEOybZFCfqtFjwbwel+0Y+Szz9RlhGqzo4zK+4XzluDxjEK9THw== 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 4Pg5ZW4D4lzLY8; Mon, 20 Mar 2023 07:14:11 +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 32K7EBQm049719; Mon, 20 Mar 2023 07:14:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32K7EBZP049718; Mon, 20 Mar 2023 07:14:11 GMT (envelope-from git) Date: Mon, 20 Mar 2023 07:14:11 GMT Message-Id: <202303200714.32K7EBZP049718@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: 7c5d3ec4c02b - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: 7c5d3ec4c02b89754ec3ce55d1b7943c404209df Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=7c5d3ec4c02b89754ec3ce55d1b7943c404209df commit 7c5d3ec4c02b89754ec3ce55d1b7943c404209df Author: Konstantin Belousov AuthorDate: 2023-03-17 13:02:03 +0000 Commit: Konstantin Belousov CommitDate: 2023-03-20 07:03:28 +0000 amd64: properly recalculate mitigations knobs after resume (cherry picked from commit 02904a06c76be857307b78184863654b9e7b88ab) --- 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;