]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
Clean up 5.10 backport of 0001-KVM-x86-emulator-update-the-emulation-mode-after-rsm...
authorSasha Levin <sashal@kernel.org>
Mon, 28 Nov 2022 02:29:16 +0000 (21:29 -0500)
committerSasha Levin <sashal@kernel.org>
Mon, 28 Nov 2022 02:29:16 +0000 (21:29 -0500)
queue-5.10/kbuild-refactor-single-builds-of-.ko.patch [deleted file]
queue-5.10/kbuild-remove-unneeded-mkdir-for-external-modules_in.patch [deleted file]
queue-5.10/kbuild-unify-modules-_install-for-in-tree-and-extern.patch [deleted file]
queue-5.10/kvm-x86-drop-.post_leave_smm-i.e.-the-manual-post-rs.patch [deleted file]
queue-5.10/kvm-x86-emulate-triple-fault-shutdown-if-rsm-emulati.patch [deleted file]
queue-5.10/kvm-x86-emulator-update-the-emulation-mode-after-rsm.patch
queue-5.10/kvm-x86-invoke-kvm_smm_changed-immediately-after-cle.patch [deleted file]
queue-5.10/kvm-x86-replace-.set_hflags-with-dedicated-.exiting_.patch [deleted file]
queue-5.10/series

diff --git a/queue-5.10/kbuild-refactor-single-builds-of-.ko.patch b/queue-5.10/kbuild-refactor-single-builds-of-.ko.patch
deleted file mode 100644 (file)
index 3d4b611..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-From 880750ab053e6202f4d9ce3a8174a0e9dda1b96d Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Sun, 28 Aug 2022 11:39:50 +0900
-Subject: kbuild: refactor single builds of *.ko
-
-From: Masahiro Yamada <masahiroy@kernel.org>
-
-[ Upstream commit f110e5a250e3c5db417e094b3dd86f1c135291ca ]
-
-Remove the potentially invalid modules.order instead of using
-the temporary file.
-
-Also, KBUILD_MODULES is don't care for single builds. No need to
-cancel it.
-
-Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
-Stable-dep-of: 055f37f84e30 ("KVM: x86: emulator: update the emulation mode after rsm")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- Makefile | 16 ++++------------
- 1 file changed, 4 insertions(+), 12 deletions(-)
-
-diff --git a/Makefile b/Makefile
-index 8994b6f13b13..f737f1c4e2b8 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1766,6 +1766,8 @@ modules modules_install:
-       @echo >&2 '***'
-       @exit 1
-+KBUILD_MODULES :=
-+
- endif # CONFIG_MODULES
- # Single targets
-@@ -1791,18 +1793,12 @@ $(single-ko): single_modpost
- $(single-no-ko): descend
-       @:
--ifeq ($(KBUILD_EXTMOD),)
--# For the single build of in-tree modules, use a temporary file to avoid
--# the situation of modules_install installing an invalid modules.order.
--MODORDER := .modules.tmp
--endif
--
-+# Remove MODORDER when done because it is not the real one.
- PHONY += single_modpost
- single_modpost: $(single-no-ko) modules_prepare
-       $(Q){ $(foreach m, $(single-ko), echo $(extmod-prefix)$m;) } > $(MODORDER)
-       $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
--
--KBUILD_MODULES := 1
-+      $(Q)rm -f $(MODORDER)
- export KBUILD_SINGLE_TARGETS := $(addprefix $(extmod-prefix), $(single-no-ko))
-@@ -1812,10 +1808,6 @@ build-dirs := $(foreach d, $(build-dirs), \
- endif
--ifndef CONFIG_MODULES
--KBUILD_MODULES :=
--endif
--
- # Handle descending into subdirectories listed in $(build-dirs)
- # Preset locale variables to speed up the build process. Limit locale
- # tweaks to this spot to avoid wrong language settings when running
--- 
-2.35.1
-
diff --git a/queue-5.10/kbuild-remove-unneeded-mkdir-for-external-modules_in.patch b/queue-5.10/kbuild-remove-unneeded-mkdir-for-external-modules_in.patch
deleted file mode 100644 (file)
index 719f6b7..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-From 1f2fcfb7aa5bfc58a673ceda542b47b14ba6c838 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 31 Mar 2021 22:38:02 +0900
-Subject: kbuild: remove unneeded mkdir for external modules_install
-
-From: Masahiro Yamada <masahiroy@kernel.org>
-
-[ Upstream commit 4b97ec0e9cfd5995f41b9726c88566a31f4625cc ]
-
-scripts/Makefile.modinst creates directories as needed.
-
-Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
-Stable-dep-of: 055f37f84e30 ("KVM: x86: emulator: update the emulation mode after rsm")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- Makefile | 2 --
- 1 file changed, 2 deletions(-)
-
-diff --git a/Makefile b/Makefile
-index 166f87bdc190..9eacc623642c 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1746,10 +1746,8 @@ $(MODORDER): descend
- PHONY += modules_install
- modules_install: _emodinst_ _emodinst_post
--install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
- PHONY += _emodinst_
- _emodinst_:
--      $(Q)mkdir -p $(MODLIB)/$(install-dir)
-       $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
- PHONY += _emodinst_post
--- 
-2.35.1
-
diff --git a/queue-5.10/kbuild-unify-modules-_install-for-in-tree-and-extern.patch b/queue-5.10/kbuild-unify-modules-_install-for-in-tree-and-extern.patch
deleted file mode 100644 (file)
index 342a398..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-From 521e0b2271424bc36bdd788b98b4b9d2850d7056 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 31 Mar 2021 22:38:03 +0900
-Subject: kbuild: unify modules(_install) for in-tree and external modules
-
-From: Masahiro Yamada <masahiroy@kernel.org>
-
-[ Upstream commit 3e3005df73b535cb849cf4ec8075d6aa3c460f68 ]
-
-If you attempt to build or install modules ('make modules(_install)'
-with CONFIG_MODULES disabled, you will get a clear error message, but
-nothing for external module builds.
-
-Factor out the modules and modules_install rules into the common part,
-so you will get the same error message when you try to build external
-modules with CONFIG_MODULES=n.
-
-Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
-Stable-dep-of: 055f37f84e30 ("KVM: x86: emulator: update the emulation mode after rsm")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- Makefile | 85 ++++++++++++++++++++++++--------------------------------
- 1 file changed, 36 insertions(+), 49 deletions(-)
-
-diff --git a/Makefile b/Makefile
-index 9eacc623642c..8994b6f13b13 100644
---- a/Makefile
-+++ b/Makefile
-@@ -1425,7 +1425,6 @@ endif
- PHONY += modules
- modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_check modules_prepare
--      $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
- PHONY += modules_check
- modules_check: modules.order
-@@ -1443,12 +1442,9 @@ PHONY += modules_prepare
- modules_prepare: prepare
-       $(Q)$(MAKE) $(build)=scripts scripts/module.lds
--# Target to install modules
--PHONY += modules_install
--modules_install: _modinst_ _modinst_post
--
--PHONY += _modinst_
--_modinst_:
-+modules_install: __modinst_pre
-+PHONY += __modinst_pre
-+__modinst_pre:
-       @rm -rf $(MODLIB)/kernel
-       @rm -f $(MODLIB)/source
-       @mkdir -p $(MODLIB)/kernel
-@@ -1460,14 +1456,6 @@ _modinst_:
-       @sed 's:^:kernel/:' modules.order > $(MODLIB)/modules.order
-       @cp -f modules.builtin $(MODLIB)/
-       @cp -f $(objtree)/modules.builtin.modinfo $(MODLIB)/
--      $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
--
--# This depmod is only for convenience to give the initial
--# boot a modules.dep even before / is mounted read-write.  However the
--# boot script depmod is the master version.
--PHONY += _modinst_post
--_modinst_post: _modinst_
--      $(call cmd,depmod)
- ifeq ($(CONFIG_MODULE_SIG), y)
- PHONY += modules_sign
-@@ -1475,20 +1463,6 @@ modules_sign:
-       $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modsign
- endif
--else # CONFIG_MODULES
--
--# Modules not configured
--# ---------------------------------------------------------------------------
--
--PHONY += modules modules_install
--modules modules_install:
--      @echo >&2
--      @echo >&2 "The present kernel configuration has modules disabled."
--      @echo >&2 "Type 'make config' and enable loadable module support."
--      @echo >&2 "Then build a kernel with module support enabled."
--      @echo >&2
--      @exit 1
--
- endif # CONFIG_MODULES
- ###
-@@ -1736,24 +1710,9 @@ KBUILD_BUILTIN :=
- KBUILD_MODULES := 1
- build-dirs := $(KBUILD_EXTMOD)
--PHONY += modules
--modules: $(MODORDER)
--      $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
--
- $(MODORDER): descend
-       @:
--PHONY += modules_install
--modules_install: _emodinst_ _emodinst_post
--
--PHONY += _emodinst_
--_emodinst_:
--      $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
--
--PHONY += _emodinst_post
--_emodinst_post: _emodinst_
--      $(call cmd,depmod)
--
- compile_commands.json: $(extmod-prefix)compile_commands.json
- PHONY += compile_commands.json
-@@ -1776,6 +1735,39 @@ PHONY += prepare modules_prepare
- endif # KBUILD_EXTMOD
-+# ---------------------------------------------------------------------------
-+# Modules
-+
-+PHONY += modules modules_install
-+
-+ifdef CONFIG_MODULES
-+
-+modules: $(MODORDER)
-+      $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
-+
-+quiet_cmd_depmod = DEPMOD  $(KERNELRELEASE)
-+      cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
-+                   $(KERNELRELEASE)
-+
-+modules_install:
-+      $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
-+      $(call cmd,depmod)
-+
-+else # CONFIG_MODULES
-+
-+# Modules not configured
-+# ---------------------------------------------------------------------------
-+
-+modules modules_install:
-+      @echo >&2 '***'
-+      @echo >&2 '*** The present kernel configuration has modules disabled.'
-+      @echo >&2 '*** To use the module feature, please run "make menuconfig" etc.'
-+      @echo >&2 '*** to enable CONFIG_MODULES.'
-+      @echo >&2 '***'
-+      @exit 1
-+
-+endif # CONFIG_MODULES
-+
- # Single targets
- # ---------------------------------------------------------------------------
- # To build individual files in subdirectories, you can do like this:
-@@ -1963,11 +1955,6 @@ tools/%: FORCE
- quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   $(wildcard $(rm-files)))
-       cmd_rmfiles = rm -rf $(rm-files)
--# Run depmod only if we have System.map and depmod is executable
--quiet_cmd_depmod = DEPMOD  $(KERNELRELEASE)
--      cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \
--                   $(KERNELRELEASE)
--
- # read saved command lines for existing targets
- existing-targets := $(wildcard $(sort $(targets)))
--- 
-2.35.1
-
diff --git a/queue-5.10/kvm-x86-drop-.post_leave_smm-i.e.-the-manual-post-rs.patch b/queue-5.10/kvm-x86-drop-.post_leave_smm-i.e.-the-manual-post-rs.patch
deleted file mode 100644 (file)
index f6b66d5..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-From 44547012febf343ca7bf53890bbe2a42c22aaa0d Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 9 Jun 2021 11:56:18 -0700
-Subject: KVM: x86: Drop .post_leave_smm(), i.e. the manual post-RSM MMU reset
-
-From: Sean Christopherson <seanjc@google.com>
-
-[ Upstream commit 0128116550acf52043a0aa5cca3caa85e3853aca ]
-
-Drop the .post_leave_smm() emulator callback, which at this point is just
-a wrapper to kvm_mmu_reset_context().  The manual context reset is
-unnecessary, because unlike enter_smm() which calls vendor MSR/CR helpers
-directly, em_rsm() bounces through the KVM helpers, e.g. kvm_set_cr4(),
-which are responsible for processing side effects.  em_rsm() is already
-subtly relying on this behavior as it doesn't manually do
-kvm_update_cpuid_runtime(), e.g. to recognize CR4.OSXSAVE changes.
-
-Signed-off-by: Sean Christopherson <seanjc@google.com>
-Message-Id: <20210609185619.992058-9-seanjc@google.com>
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-Stable-dep-of: 055f37f84e30 ("KVM: x86: emulator: update the emulation mode after rsm")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/x86/kvm/emulate.c     | 10 ++++++++--
- arch/x86/kvm/kvm_emulate.h |  1 -
- arch/x86/kvm/x86.c         |  6 ------
- 3 files changed, 8 insertions(+), 9 deletions(-)
-
-diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
-index 2e6d7640c4ed..d5da89271318 100644
---- a/arch/x86/kvm/emulate.c
-+++ b/arch/x86/kvm/emulate.c
-@@ -2741,8 +2741,14 @@ static int em_rsm(struct x86_emulate_ctxt *ctxt)
-       if (ret != X86EMUL_CONTINUE)
-               goto emulate_shutdown;
--      ctxt->ops->post_leave_smm(ctxt);
--
-+      /*
-+       * Note, the ctxt->ops callbacks are responsible for handling side
-+       * effects when writing MSRs and CRs, e.g. MMU context resets, CPUID
-+       * runtime updates, etc...  If that changes, e.g. this flow is moved
-+       * out of the emulator to make it look more like enter_smm(), then
-+       * those side effects need to be explicitly handled for both success
-+       * and shutdown.
-+       */
-       return X86EMUL_CONTINUE;
- emulate_shutdown:
-diff --git a/arch/x86/kvm/kvm_emulate.h b/arch/x86/kvm/kvm_emulate.h
-index 148ba21d0646..3650db9e5ed5 100644
---- a/arch/x86/kvm/kvm_emulate.h
-+++ b/arch/x86/kvm/kvm_emulate.h
-@@ -233,7 +233,6 @@ struct x86_emulate_ops {
-       void (*exiting_smm)(struct x86_emulate_ctxt *ctxt);
-       int (*pre_leave_smm)(struct x86_emulate_ctxt *ctxt,
-                            const char *smstate);
--      void (*post_leave_smm)(struct x86_emulate_ctxt *ctxt);
-       void (*triple_fault)(struct x86_emulate_ctxt *ctxt);
-       int (*set_xcr)(struct x86_emulate_ctxt *ctxt, u32 index, u64 xcr);
- };
-diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
-index ef43bfa1b3a8..e04e97b0661c 100644
---- a/arch/x86/kvm/x86.c
-+++ b/arch/x86/kvm/x86.c
-@@ -7013,11 +7013,6 @@ static int emulator_pre_leave_smm(struct x86_emulate_ctxt *ctxt,
-       return kvm_x86_ops.pre_leave_smm(emul_to_vcpu(ctxt), smstate);
- }
--static void emulator_post_leave_smm(struct x86_emulate_ctxt *ctxt)
--{
--      kvm_mmu_reset_context(emul_to_vcpu(ctxt));
--}
--
- static void emulator_triple_fault(struct x86_emulate_ctxt *ctxt)
- {
-       kvm_make_request(KVM_REQ_TRIPLE_FAULT, emul_to_vcpu(ctxt));
-@@ -7072,7 +7067,6 @@ static const struct x86_emulate_ops emulate_ops = {
-       .get_hflags          = emulator_get_hflags,
-       .exiting_smm         = emulator_exiting_smm,
-       .pre_leave_smm       = emulator_pre_leave_smm,
--      .post_leave_smm      = emulator_post_leave_smm,
-       .triple_fault        = emulator_triple_fault,
-       .set_xcr             = emulator_set_xcr,
- };
--- 
-2.35.1
-
diff --git a/queue-5.10/kvm-x86-emulate-triple-fault-shutdown-if-rsm-emulati.patch b/queue-5.10/kvm-x86-emulate-triple-fault-shutdown-if-rsm-emulati.patch
deleted file mode 100644 (file)
index 2006e57..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-From 9d1b2beac4b61cf1f30aa0dddc85547ed61eb2cb Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 9 Jun 2021 11:56:12 -0700
-Subject: KVM: x86: Emulate triple fault shutdown if RSM emulation fails
-
-From: Sean Christopherson <seanjc@google.com>
-
-[ Upstream commit 25b17226cd9a77982fc8c915d4118d7238a0f079 ]
-
-Use the recently introduced KVM_REQ_TRIPLE_FAULT to properly emulate
-shutdown if RSM from SMM fails.
-
-Note, entering shutdown after clearing the SMM flag and restoring NMI
-blocking is architecturally correct with respect to AMD's APM, which KVM
-also uses for SMRAM layout and RSM NMI blocking behavior.  The APM says:
-
-  An RSM causes a processor shutdown if an invalid-state condition is
-  found in the SMRAM state-save area. Only an external reset, external
-  processor-initialization, or non-maskable external interrupt (NMI) can
-  cause the processor to leave the shutdown state.
-
-Of note is processor-initialization (INIT) as a valid shutdown wake
-event, as INIT is blocked by SMM, implying that entering shutdown also
-forces the CPU out of SMM.
-
-For recent Intel CPUs, restoring NMI blocking is technically wrong, but
-so is restoring NMI blocking in the first place, and Intel's RSM
-"architecture" is such a mess that just about anything is allowed and can
-be justified as micro-architectural behavior.
-
-Per the SDM:
-
-  On Pentium 4 and later processors, shutdown will inhibit INTR and A20M
-  but will not change any of the other inhibits. On these processors,
-  NMIs will be inhibited if no action is taken in the SMI handler to
-  uninhibit them (see Section 34.8).
-
-where Section 34.8 says:
-
-  When the processor enters SMM while executing an NMI handler, the
-  processor saves the SMRAM state save map but does not save the
-  attribute to keep NMI interrupts disabled. Potentially, an NMI could be
-  latched (while in SMM or upon exit) and serviced upon exit of SMM even
-  though the previous NMI handler has still not completed.
-
-I.e. RSM unconditionally unblocks NMI, but shutdown on RSM does not,
-which is in direct contradiction of KVM's behavior.  But, as mentioned
-above, KVM follows AMD architecture and restores NMI blocking on RSM, so
-that micro-architectural detail is already lost.
-
-And for Pentium era CPUs, SMI# can break shutdown, meaning that at least
-some Intel CPUs fully leave SMM when entering shutdown:
-
-  In the shutdown state, Intel processors stop executing instructions
-  until a RESET#, INIT# or NMI# is asserted.  While Pentium family
-  processors recognize the SMI# signal in shutdown state, P6 family and
-  Intel486 processors do not.
-
-In other words, the fact that Intel CPUs have implemented the two
-extremes gives KVM carte blanche when it comes to honoring Intel's
-architecture for handling shutdown during RSM.
-
-Signed-off-by: Sean Christopherson <seanjc@google.com>
-Message-Id: <20210609185619.992058-3-seanjc@google.com>
-[Return X86EMUL_CONTINUE after triple fault. - Paolo]
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-Stable-dep-of: 055f37f84e30 ("KVM: x86: emulator: update the emulation mode after rsm")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/x86/kvm/emulate.c     | 12 +++++++-----
- arch/x86/kvm/kvm_emulate.h |  1 +
- arch/x86/kvm/x86.c         |  6 ++++++
- 3 files changed, 14 insertions(+), 5 deletions(-)
-
-diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
-index 63efccc8f429..89ad10261d90 100644
---- a/arch/x86/kvm/emulate.c
-+++ b/arch/x86/kvm/emulate.c
-@@ -2730,7 +2730,7 @@ static int em_rsm(struct x86_emulate_ctxt *ctxt)
-        * state-save area.
-        */
-       if (ctxt->ops->pre_leave_smm(ctxt, buf))
--              return X86EMUL_UNHANDLEABLE;
-+              goto emulate_shutdown;
- #ifdef CONFIG_X86_64
-       if (emulator_has_longmode(ctxt))
-@@ -2739,14 +2739,16 @@ static int em_rsm(struct x86_emulate_ctxt *ctxt)
- #endif
-               ret = rsm_load_state_32(ctxt, buf);
--      if (ret != X86EMUL_CONTINUE) {
--              /* FIXME: should triple fault */
--              return X86EMUL_UNHANDLEABLE;
--      }
-+      if (ret != X86EMUL_CONTINUE)
-+              goto emulate_shutdown;
-       ctxt->ops->post_leave_smm(ctxt);
-       return X86EMUL_CONTINUE;
-+
-+emulate_shutdown:
-+      ctxt->ops->triple_fault(ctxt);
-+      return X86EMUL_CONTINUE;
- }
- static void
-diff --git a/arch/x86/kvm/kvm_emulate.h b/arch/x86/kvm/kvm_emulate.h
-index aeed6da60e0c..1da3f77a8728 100644
---- a/arch/x86/kvm/kvm_emulate.h
-+++ b/arch/x86/kvm/kvm_emulate.h
-@@ -234,6 +234,7 @@ struct x86_emulate_ops {
-       int (*pre_leave_smm)(struct x86_emulate_ctxt *ctxt,
-                            const char *smstate);
-       void (*post_leave_smm)(struct x86_emulate_ctxt *ctxt);
-+      void (*triple_fault)(struct x86_emulate_ctxt *ctxt);
-       int (*set_xcr)(struct x86_emulate_ctxt *ctxt, u32 index, u64 xcr);
- };
-diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
-index 23d7c563e012..20dc108f2c4c 100644
---- a/arch/x86/kvm/x86.c
-+++ b/arch/x86/kvm/x86.c
-@@ -7018,6 +7018,11 @@ static void emulator_post_leave_smm(struct x86_emulate_ctxt *ctxt)
-       kvm_smm_changed(emul_to_vcpu(ctxt));
- }
-+static void emulator_triple_fault(struct x86_emulate_ctxt *ctxt)
-+{
-+      kvm_make_request(KVM_REQ_TRIPLE_FAULT, emul_to_vcpu(ctxt));
-+}
-+
- static int emulator_set_xcr(struct x86_emulate_ctxt *ctxt, u32 index, u64 xcr)
- {
-       return __kvm_set_xcr(emul_to_vcpu(ctxt), index, xcr);
-@@ -7068,6 +7073,7 @@ static const struct x86_emulate_ops emulate_ops = {
-       .set_hflags          = emulator_set_hflags,
-       .pre_leave_smm       = emulator_pre_leave_smm,
-       .post_leave_smm      = emulator_post_leave_smm,
-+      .triple_fault        = emulator_triple_fault,
-       .set_xcr             = emulator_set_xcr,
- };
--- 
-2.35.1
-
index e7d477081aeceb2c44d590390d4bd1854fdb6c81..a6cbf57c277ec52cd1cdf75abb6f360bc3a66f96 100644 (file)
@@ -1,4 +1,4 @@
-From 74c87e6e5b654a2e15ca1ec3a9b9818a6499c979 Mon Sep 17 00:00:00 2001
+From 1a486c91185478cad25036affe91050eebd95be6 Mon Sep 17 00:00:00 2001
 From: Sasha Levin <sashal@kernel.org>
 Date: Tue, 25 Oct 2022 15:47:30 +0300
 Subject: KVM: x86: emulator: update the emulation mode after rsm
@@ -20,22 +20,29 @@ Cc: stable@vger.kernel.org
 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
 Signed-off-by: Sasha Levin <sashal@kernel.org>
 ---
- arch/x86/kvm/emulate.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
+ arch/x86/kvm/emulate.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
 
 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
-index d5da89271318..2022a27f0c26 100644
+index 63efccc8f429..716d54b624e0 100644
 --- a/arch/x86/kvm/emulate.c
 +++ b/arch/x86/kvm/emulate.c
-@@ -2749,7 +2749,7 @@ static int em_rsm(struct x86_emulate_ctxt *ctxt)
-        * those side effects need to be explicitly handled for both success
-        * and shutdown.
-        */
--      return X86EMUL_CONTINUE;
-+      return emulator_recalc_and_set_mode(ctxt);
+@@ -2746,6 +2746,15 @@ static int em_rsm(struct x86_emulate_ctxt *ctxt)
+       ctxt->ops->post_leave_smm(ctxt);
++      /*
++       * Note, the ctxt->ops callbacks are responsible for handling side
++       * effects when writing MSRs and CRs, e.g. MMU context resets, CPUID
++       * runtime updates, etc...  If that changes, e.g. this flow is moved
++       * out of the emulator to make it look more like enter_smm(), then
++       * those side effects need to be explicitly handled for both success
++       * and shutdown.
++       */
++
+       return X86EMUL_CONTINUE;
+ }
  
- emulate_shutdown:
-       ctxt->ops->triple_fault(ctxt);
 -- 
 2.35.1
 
diff --git a/queue-5.10/kvm-x86-invoke-kvm_smm_changed-immediately-after-cle.patch b/queue-5.10/kvm-x86-invoke-kvm_smm_changed-immediately-after-cle.patch
deleted file mode 100644 (file)
index c5568d2..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-From a8b62eccd42f0f4ba325d420ba74865e870b3903 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 9 Jun 2021 11:56:14 -0700
-Subject: KVM: x86: Invoke kvm_smm_changed() immediately after clearing SMM
- flag
-
-From: Sean Christopherson <seanjc@google.com>
-
-[ Upstream commit fa75e08bbe4f8ea609f61bbb6c04b3bb2b38c793 ]
-
-Move RSM emulation's call to kvm_smm_changed() from .post_leave_smm() to
-.exiting_smm(), leaving behind the MMU context reset.  The primary
-motivation is to allow for future cleanup, but this also fixes a bug of
-sorts by queueing KVM_REQ_EVENT even if RSM causes shutdown, e.g. to let
-an INIT wake the vCPU from shutdown.  Of course, KVM doesn't properly
-emulate a shutdown state, e.g. KVM doesn't block SMIs after shutdown, and
-immediately exits to userspace, so the event request is a moot point in
-practice.
-
-Moving kvm_smm_changed() also moves the RSM tracepoint.  This isn't
-strictly necessary, but will allow consolidating the SMI and RSM
-tracepoints in a future commit (by also moving the SMI tracepoint).
-Invoking the tracepoint before loading SMRAM state also means the SMBASE
-that reported in the tracepoint will point that the state that will be
-used for RSM, as opposed to the SMBASE _after_ RSM completes, which is
-arguably a good thing if the tracepoint is being used to debug a RSM/SMM
-issue.
-
-Signed-off-by: Sean Christopherson <seanjc@google.com>
-Message-Id: <20210609185619.992058-5-seanjc@google.com>
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-Stable-dep-of: 055f37f84e30 ("KVM: x86: emulator: update the emulation mode after rsm")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/x86/kvm/x86.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
-
-diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
-index 0afae6755868..ef43bfa1b3a8 100644
---- a/arch/x86/kvm/x86.c
-+++ b/arch/x86/kvm/x86.c
-@@ -7004,7 +7004,7 @@ static void emulator_exiting_smm(struct x86_emulate_ctxt *ctxt)
-       struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
-       vcpu->arch.hflags &= ~(HF_SMM_MASK | HF_SMM_INSIDE_NMI_MASK);
--      kvm_mmu_reset_context(vcpu);
-+      kvm_smm_changed(vcpu);
- }
- static int emulator_pre_leave_smm(struct x86_emulate_ctxt *ctxt,
-@@ -7015,7 +7015,7 @@ static int emulator_pre_leave_smm(struct x86_emulate_ctxt *ctxt,
- static void emulator_post_leave_smm(struct x86_emulate_ctxt *ctxt)
- {
--      kvm_smm_changed(emul_to_vcpu(ctxt));
-+      kvm_mmu_reset_context(emul_to_vcpu(ctxt));
- }
- static void emulator_triple_fault(struct x86_emulate_ctxt *ctxt)
--- 
-2.35.1
-
diff --git a/queue-5.10/kvm-x86-replace-.set_hflags-with-dedicated-.exiting_.patch b/queue-5.10/kvm-x86-replace-.set_hflags-with-dedicated-.exiting_.patch
deleted file mode 100644 (file)
index c0782cd..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-From 39c833834eb63d070825844a7673887405e77f61 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Wed, 9 Jun 2021 11:56:13 -0700
-Subject: KVM: x86: Replace .set_hflags() with dedicated .exiting_smm() helper
-
-From: Sean Christopherson <seanjc@google.com>
-
-[ Upstream commit edce46548b70b8637694d96122447662ff35af0c ]
-
-Replace the .set_hflags() emulator hook with a dedicated .exiting_smm(),
-moving the SMM and SMM_INSIDE_NMI flag handling out of the emulator in
-the process.  This is a step towards consolidating much of the logic in
-kvm_smm_changed(), including the SMM hflags updates.
-
-No functional change intended.
-
-Signed-off-by: Sean Christopherson <seanjc@google.com>
-Message-Id: <20210609185619.992058-4-seanjc@google.com>
-Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-Stable-dep-of: 055f37f84e30 ("KVM: x86: emulator: update the emulation mode after rsm")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/x86/kvm/emulate.c     | 3 +--
- arch/x86/kvm/kvm_emulate.h | 2 +-
- arch/x86/kvm/x86.c         | 6 +++---
- 3 files changed, 5 insertions(+), 6 deletions(-)
-
-diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
-index 89ad10261d90..2e6d7640c4ed 100644
---- a/arch/x86/kvm/emulate.c
-+++ b/arch/x86/kvm/emulate.c
-@@ -2685,8 +2685,7 @@ static int em_rsm(struct x86_emulate_ctxt *ctxt)
-       if ((ctxt->ops->get_hflags(ctxt) & X86EMUL_SMM_INSIDE_NMI_MASK) == 0)
-               ctxt->ops->set_nmi_mask(ctxt, false);
--      ctxt->ops->set_hflags(ctxt, ctxt->ops->get_hflags(ctxt) &
--              ~(X86EMUL_SMM_INSIDE_NMI_MASK | X86EMUL_SMM_MASK));
-+      ctxt->ops->exiting_smm(ctxt);
-       /*
-        * Get back to real mode, to prepare a safe state in which to load
-diff --git a/arch/x86/kvm/kvm_emulate.h b/arch/x86/kvm/kvm_emulate.h
-index 1da3f77a8728..148ba21d0646 100644
---- a/arch/x86/kvm/kvm_emulate.h
-+++ b/arch/x86/kvm/kvm_emulate.h
-@@ -230,7 +230,7 @@ struct x86_emulate_ops {
-       void (*set_nmi_mask)(struct x86_emulate_ctxt *ctxt, bool masked);
-       unsigned (*get_hflags)(struct x86_emulate_ctxt *ctxt);
--      void (*set_hflags)(struct x86_emulate_ctxt *ctxt, unsigned hflags);
-+      void (*exiting_smm)(struct x86_emulate_ctxt *ctxt);
-       int (*pre_leave_smm)(struct x86_emulate_ctxt *ctxt,
-                            const char *smstate);
-       void (*post_leave_smm)(struct x86_emulate_ctxt *ctxt);
-diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
-index 20dc108f2c4c..0afae6755868 100644
---- a/arch/x86/kvm/x86.c
-+++ b/arch/x86/kvm/x86.c
-@@ -6999,11 +6999,11 @@ static unsigned emulator_get_hflags(struct x86_emulate_ctxt *ctxt)
-       return emul_to_vcpu(ctxt)->arch.hflags;
- }
--static void emulator_set_hflags(struct x86_emulate_ctxt *ctxt, unsigned emul_flags)
-+static void emulator_exiting_smm(struct x86_emulate_ctxt *ctxt)
- {
-       struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
--      vcpu->arch.hflags = emul_flags;
-+      vcpu->arch.hflags &= ~(HF_SMM_MASK | HF_SMM_INSIDE_NMI_MASK);
-       kvm_mmu_reset_context(vcpu);
- }
-@@ -7070,7 +7070,7 @@ static const struct x86_emulate_ops emulate_ops = {
-       .guest_has_rdpid     = emulator_guest_has_rdpid,
-       .set_nmi_mask        = emulator_set_nmi_mask,
-       .get_hflags          = emulator_get_hflags,
--      .set_hflags          = emulator_set_hflags,
-+      .exiting_smm         = emulator_exiting_smm,
-       .pre_leave_smm       = emulator_pre_leave_smm,
-       .post_leave_smm      = emulator_post_leave_smm,
-       .triple_fault        = emulator_triple_fault,
--- 
-2.35.1
-
index 03b86a0e340d84533a2f3462750a691671c27a5b..05d6abfcb9dae5600a55f7d8a81043bae99c2dec 100644 (file)
@@ -92,13 +92,6 @@ net-enetc-preserve-tx-ring-priority-across-reconfigu.patch
 lib-vdso-use-grep-e-instead-of-egrep.patch
 init-kconfig-fix-cc_has_asm_goto_tied_output-test-wi.patch
 nios2-add-force-for-vmlinuz.gz.patch
-kbuild-remove-unneeded-mkdir-for-external-modules_in.patch
-kbuild-unify-modules-_install-for-in-tree-and-extern.patch
-kvm-x86-emulate-triple-fault-shutdown-if-rsm-emulati.patch
-kvm-x86-replace-.set_hflags-with-dedicated-.exiting_.patch
-kvm-x86-invoke-kvm_smm_changed-immediately-after-cle.patch
-kvm-x86-drop-.post_leave_smm-i.e.-the-manual-post-rs.patch
-kbuild-refactor-single-builds-of-.ko.patch
 kvm-x86-emulator-update-the-emulation-mode-after-rsm.patch
 mmc-sdhci-brcmstb-re-organize-flags.patch
 mmc-sdhci-brcmstb-enable-clock-gating-to-save-power.patch