[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 2/3] x86/shadow: mark more of sh_page_fault() HVM-only


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 23 Jan 2023 15:27:29 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RrwYPI3hJNohdFkp2eOgTzxDlzUCzI3WQX/iB1o8qcY=; b=NszGQ2wLV+rey8pCha3anzNR9cJAC9QScKS4nFNqZBq7mBSTHtILzotMMkUGdE8yFX2VUYKOso9PYlsgCTgOCeWi8kwmDt3tjtNCA8iBNg2Drj3E5hI7C9zUDTWsglpOezHsn9f4QD/msyXMYet+fX7dNfx/SKmPU8PHL7jjuXbjB/RzMQXDaef9G4gpP08nqwKg66HytfUPUKDRxIAeoRyCbqkNs1F98uE85gqzO9Dw/rvMeaUlQDi5pd74NrNKzV4Egjg98qtjlgz07ucUB4YAxo4yEhaSzsnwkXsj9+a1ONXA/ut3P5+NgLt11S8h70NQFqEQtzoY7EtrRk4H6g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CFhPwne6xGjpzyuaAr+F18YfrsCiFaZy2rZf6chyGVX6MeppfChgis2uymYtxsQ3DB0+tG1qSw2LEypfHEea3dIQqAgEYUwQEzsmJ479GSpyMkcXOasmyMN2C0L0IqChaEqtdAD/Wu6nMoTp111JZyovSb4PpZ8SmhHKcWZRqBKiujGCbwWhpvThxSlrAxqyXI9nLhOLRYDi/OvSedwweQPlFTOqHagUcLTYfvidPWVye2NIrtXKeCXZ1c9P9cUb3qwbpBeEYUBtM/oR8SLD7lvaO+vx586buEe6msb8NEB/tzd+mq8sDOIlEEYmy4Bd0FJ2dKrJqTnaZiJmycp09w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Tim Deegan <tim@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>
  • Delivery-date: Mon, 23 Jan 2023 14:27:34 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The types p2m_is_readonly() checks for aren't applicable to PV;
specifically get_gfn() won't ever return any such type for PV domains.
Extend the HVM-conditional block of code, also past the subsequent HVM-
only if(). This way the "emulate_readonly" also becomes unreachable when
!HVM, so move the conditional there upwards as well. Noticing the
earlier shadow_mode_refcounts() check, move it up even further, right
after that check. With that, the "done" label also needs marking as
potentially unused.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: Parts split off to a subsequent patch.

--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -2613,8 +2613,6 @@ static int cf_check sh_page_fault(
                ? EXCRET_fault_fixed : 0;
     }
 
-#endif /* CONFIG_HVM */
-
     /* Ignore attempts to write to read-only memory. */
     if ( p2m_is_readonly(p2mt) && (ft == ft_demand_write) )
         goto emulate_readonly; /* skip over the instruction */
@@ -2633,12 +2631,14 @@ static int cf_check sh_page_fault(
         goto emulate;
     }
 
+#endif /* CONFIG_HVM */
+
     perfc_incr(shadow_fault_fixed);
     d->arch.paging.log_dirty.fault_count++;
     sh_reset_early_unshadow(v);
 
     trace_shadow_fixup(gw.l1e, va);
- done:
+ done: __maybe_unused;
     sh_audit_gw(v, &gw);
     SHADOW_PRINTK("fixed\n");
     shadow_audit_tables(v);
@@ -2650,6 +2650,7 @@ static int cf_check sh_page_fault(
     if ( !shadow_mode_refcounts(d) || !guest_mode(regs) )
         goto not_a_shadow_fault;
 
+#ifdef CONFIG_HVM
     /*
      * We do not emulate user writes. Instead we use them as a hint that the
      * page is no longer a page table. This behaviour differs from native, but
@@ -2677,7 +2678,6 @@ static int cf_check sh_page_fault(
         goto not_a_shadow_fault;
     }
 
-#ifdef CONFIG_HVM
     /* Unshadow if we are writing to a toplevel pagetable that is
      * flagged as a dying process, and that is not currently used. */
     if ( sh_mfn_is_a_page_table(gmfn) && is_hvm_domain(d) &&




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.