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

[PATCH v2 3/3] x86/shadow: drop dead code from HVM-only sh_page_fault() pieces


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 23 Jan 2023 15:27:52 +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=McZZ2tlCGU0FnMGSjQr1T5hsn4TnYmgsmEZY2V3Kj+A=; b=CkkdDGnH9NWjPF59RfvXw/TmW/xdd5O0cDuNj2It3DAHGy233oCIdJHAbw7KhWJ0OlVkCt/X4kWUuHKEs8poc+ABqBBk7ELCMQEp66kSalVsknm0+WNO6ieDMzwhQmV7pSviVHVfh4EMXe16/A26telT14Iym5PSerr5kk8KXwZhQILQEHsYe/N4KgK7jMK9J49PTOUwkJ9MpNTeRICanZUVxxpa5WQ83AB3PlonInoornB1tnCr0D3q2oPbdrqhOe2w/Bt3MQeJsbgQryPEapeL3e4VEw7wgTueEPKZFcZHW5wdnb+/SAFUCbFOwgbeZnPlP2LXpsBu+j1wp9azSA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AsecHomFVzxaFf3PXbHir0jtjtkILKpmoJwrJpkk0vhagcAg0Y3BqC/VZ6G56T9dg3FN//Ac61BiWKQFVmTsa9rhXf2vJjj4EZa8c3uJhFCMG+e6V7D3uUquAxZaCdJEuFbJTidzJ4mHoQY3cG1NToe0qdinlEBcR4LCy+i7B23Wr9aycamnVqVsfiYSPy3g9EwOyAKyfzsggOaomHwM/UuUO6XcZH7MU72Lyq0p1RmEW8pPFGJwpeT32LjisNi2gfrN/oVXUF6NOHjh+xFJYpDOW3H2YpEAex71UJF9fLkH/jZMTrzBHtVvozSRck68BYEcdZeQPCYcbP6wO6hTmg==
  • 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:58 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The shadow_mode_refcounts() check immediately ahead of the "emulate"
label renders redundant two subsequent is_hvm_domain() checks (the
latter of which was already redundant with the former).

Also guest_mode() checks are pointless when we already know we're
dealing with a HVM domain.

Finally style-adjust a comment which otherwise would be fully visible as
patch context anyway.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: New, split off from earlier patch.

--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -2594,8 +2594,6 @@ static int cf_check sh_page_fault(
     if ( p2mt == p2m_mmio_dm )
     {
         ASSERT(is_hvm_vcpu(v));
-        if ( !guest_mode(regs) )
-            goto not_a_shadow_fault;
 
         sh_audit_gw(v, &gw);
         gpa = guest_walk_to_gpa(&gw);
@@ -2647,7 +2645,7 @@ static int cf_check sh_page_fault(
     return EXCRET_fault_fixed;
 
  emulate:
-    if ( !shadow_mode_refcounts(d) || !guest_mode(regs) )
+    if ( !shadow_mode_refcounts(d) )
         goto not_a_shadow_fault;
 
 #ifdef CONFIG_HVM
@@ -2672,16 +2670,11 @@ static int cf_check sh_page_fault(
      * caught by user-mode page-table check above.
      */
  emulate_readonly:
-    if ( !is_hvm_domain(d) )
-    {
-        ASSERT_UNREACHABLE();
-        goto not_a_shadow_fault;
-    }
-
-    /* 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) &&
-         mfn_to_page(gmfn)->pagetable_dying )
+    /*
+     * 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) && mfn_to_page(gmfn)->pagetable_dying )
     {
         int used = 0;
         struct vcpu *tmp;




 


Rackspace

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