public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Pavel Shirshov <ru.pchel@gmail.com>,
	Xiao Guangrong <guangrong.xiao@linux.intel.com>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: [PATCH 3.14 19/29] KVM: MMU: fix validation of mmio page fault
Date: Sat, 19 Sep 2015 10:27:41 -0700	[thread overview]
Message-ID: <20150919171918.991195652@linuxfoundation.org> (raw)
In-Reply-To: <20150919171918.169368855@linuxfoundation.org>

3.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Xiao Guangrong <guangrong.xiao@linux.intel.com>

commit 6f691251c0350ac52a007c54bf3ef62e9d8cdc5e upstream.

We got the bug that qemu complained with "KVM: unknown exit, hardware
reason 31" and KVM shown these info:
[84245.284948] EPT: Misconfiguration.
[84245.285056] EPT: GPA: 0xfeda848
[84245.285154] ept_misconfig_inspect_spte: spte 0x5eaef50107 level 4
[84245.285344] ept_misconfig_inspect_spte: spte 0x5f5fadc107 level 3
[84245.285532] ept_misconfig_inspect_spte: spte 0x5141d18107 level 2
[84245.285723] ept_misconfig_inspect_spte: spte 0x52e40dad77 level 1

This is because we got a mmio #PF and the handler see the mmio spte becomes
normal (points to the ram page)

However, this is valid after introducing fast mmio spte invalidation which
increases the generation-number instead of zapping mmio sptes, a example
is as follows:
1. QEMU drops mmio region by adding a new memslot
2. invalidate all mmio sptes
3.

        VCPU 0                        VCPU 1
    access the invalid mmio spte
                            access the region originally was MMIO before
                            set the spte to the normal ram map

    mmio #PF
    check the spte and see it becomes normal ram mapping !!!

This patch fixes the bug just by dropping the check in mmio handler, it's
good for backport. Full check will be introduced in later patches

Reported-by: Pavel Shirshov <ru.pchel@gmail.com>
Tested-by: Pavel Shirshov <ru.pchel@gmail.com>
Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/x86/kvm/mmu.c |   45 ---------------------------------------------
 1 file changed, 45 deletions(-)

--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -381,12 +381,6 @@ static u64 __get_spte_lockless(u64 *spte
 {
 	return ACCESS_ONCE(*sptep);
 }
-
-static bool __check_direct_spte_mmio_pf(u64 spte)
-{
-	/* It is valid if the spte is zapped. */
-	return spte == 0ull;
-}
 #else
 union split_spte {
 	struct {
@@ -502,23 +496,6 @@ retry:
 
 	return spte.spte;
 }
-
-static bool __check_direct_spte_mmio_pf(u64 spte)
-{
-	union split_spte sspte = (union split_spte)spte;
-	u32 high_mmio_mask = shadow_mmio_mask >> 32;
-
-	/* It is valid if the spte is zapped. */
-	if (spte == 0ull)
-		return true;
-
-	/* It is valid if the spte is being zapped. */
-	if (sspte.spte_low == 0ull &&
-	    (sspte.spte_high & high_mmio_mask) == high_mmio_mask)
-		return true;
-
-	return false;
-}
 #endif
 
 static bool spte_is_locklessly_modifiable(u64 spte)
@@ -3215,21 +3192,6 @@ static bool quickly_check_mmio_pf(struct
 	return vcpu_match_mmio_gva(vcpu, addr);
 }
 
-
-/*
- * On direct hosts, the last spte is only allows two states
- * for mmio page fault:
- *   - It is the mmio spte
- *   - It is zapped or it is being zapped.
- *
- * This function completely checks the spte when the last spte
- * is not the mmio spte.
- */
-static bool check_direct_spte_mmio_pf(u64 spte)
-{
-	return __check_direct_spte_mmio_pf(spte);
-}
-
 static u64 walk_shadow_page_get_mmio_spte(struct kvm_vcpu *vcpu, u64 addr)
 {
 	struct kvm_shadow_walk_iterator iterator;
@@ -3272,13 +3234,6 @@ int handle_mmio_page_fault_common(struct
 	}
 
 	/*
-	 * It's ok if the gva is remapped by other cpus on shadow guest,
-	 * it's a BUG if the gfn is not a mmio page.
-	 */
-	if (direct && !check_direct_spte_mmio_pf(spte))
-		return RET_MMIO_PF_BUG;
-
-	/*
 	 * If the page table is zapped by other cpus, let CPU fault again on
 	 * the address.
 	 */



  parent reply	other threads:[~2015-09-19 18:35 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-19 17:27 [PATCH 3.14 00/29] 3.14.53-stable review Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 01/29] DRM - radeon: Dont link train DisplayPort on HPD until we get the dpcd Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 02/29] drm/qxl: validate monitors config modes Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 03/29] s390/sclp: fix compile error Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 04/29] iio: bmg160: IIO_BUFFER and IIO_TRIGGERED_BUFFER are required Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 05/29] iio: event: Remove negative error code from iio_event_poll Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 06/29] iio: industrialio-buffer: Fix iio_buffer_poll return value Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 07/29] iio: Add inverse unit conversion macros Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 08/29] iio: adis16480: Fix scale factors Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 09/29] staging: comedi: adl_pci7x3x: fix digital output on PCI-7230 Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 10/29] clk: versatile: off by one in clk_sp810_timerclken_of_get() Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 11/29] PCI: Fix TI816X class code quirk Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 12/29] USB: symbolserial: Use usb_get_serial_port_data Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 13/29] USB: ftdi_sio: Added custom PID for CustomWare products Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 14/29] usb: dwc3: ep0: Fix mem corruption on OUT transfers of more than 512 bytes Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 15/29] usb: host: ehci-sys: delete useless bus_to_hcd conversion Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 16/29] serial: 8250: dont bind to SMSC IrCC IR port Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 17/29] crypto: ghash-clmulni: specify context size for ghash async algorithm Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 18/29] HID: usbhid: Fix the check for HID_RESET_PENDING in hid_io_error Greg Kroah-Hartman
2015-09-19 17:27 ` Greg Kroah-Hartman [this message]
2015-09-19 17:27 ` [PATCH 3.14 20/29] xtensa: fix threadptr reload on return to userspace Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 21/29] xtensa: fix kernel register spilling Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 22/29] devres: fix devres_get() Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 23/29] Doc: ABI: testing: configfs-usb-gadget-loopback Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 24/29] Doc: ABI: testing: configfs-usb-gadget-sourcesink Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 25/29] auxdisplay: ks0108: fix refcount Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 26/29] of/address: Dont loop forever in of_find_matching_node_by_address() Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 27/29] ARM: OMAP2+: DRA7: clockdomain: change l4per2_7xx_clkdm to SW_WKUP Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 28/29] drivercore: Fix unregistration path of platform devices Greg Kroah-Hartman
2015-09-19 17:27 ` [PATCH 3.14 29/29] hpfs: update ctime and mtime on directory modification Greg Kroah-Hartman
2015-09-20  0:19 ` [PATCH 3.14 00/29] 3.14.53-stable review Guenter Roeck
2015-09-21  1:44   ` Greg Kroah-Hartman
2015-09-21  7:08 ` Sudip Mukherjee
2015-09-21 16:24 ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150919171918.991195652@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=guangrong.xiao@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=ru.pchel@gmail.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox