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

[PATCH v2 6/9] x86/shadow: re-work 4-level SHADOW_FOREACH_L2E()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 11 Jan 2023 14:54:38 +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=+A1uJIX8hCVYxMZpSUyJ3UOaNSMYMDBoFU6vGM6iCfg=; b=ZFVuMt3mAXTXntaYkgz/BRN3GtdwR7DDbyo2AL6oRH8Nz3lP/fUHEYmmmsqY0TPv5Qgz4oyTfc+ruFgX6WTZe66E85NXPcWKELzZ0oYWL7xhC0RnF1VUPQG2dYiG9u9Q+dCd5sYctXVmvKOkDo/pdwhYRsAylsYc3uFTxkOldJsVX8B283OMV9bt1aiQDQE6FzRc2mMnfF2Ocnp/0IRt9ucbYoUVVZfAWvuu89fLs8V7dev7MywsglWEgu2aQU9VHvt1ov/SWqkXRysPZCg/Kf9w6+YhtWkUpHVll9euzK4k76P70I9e7eY7kcO2mnwdt4jFaRsraGXrGedM2DWBhg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ef4eBs+AKiiy090udEb1VC+i9u//RYUJ5ou3mdLgQ9b6v0NqFQZm3eOYB/2LvKMsMQza4tj4RkVFhV1PXHJI6VJyJbiFPAKMAcfnEFsuSCbco8F3PbSaUozDvVb5GKQdJvFGCu1Z2pwb3GNsS7dIy3CT85Fh4sw2nG95zVepUBfHQaVQORMxlIlmAvrRf5Zcm7DQdiwoVMzH58trVcID0Hw8LTQgpDs8SNBs9tpusHwuXTL8ZCnUGq4SUHdHDWUkJ3ZG9avyKxF4OUWIxAEZQUX5TS+/pQ2oIDcsrrRXfxrr8+LwuC+hr2fo4NY+jAiENdlTLFlnfI/TDt2mfR4Tlg==
  • 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: Wed, 11 Jan 2023 13:55:11 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

First of all move the almost loop-invariant condition out of the loop;
transform it into an altered loop boundary. Since the new local variable
wants to be "unsigned int" and named without violating name space rules,
convert the loop induction variable accordingly.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
v2: New.

--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -863,23 +863,20 @@ do {
 /* 64-bit l2: touch all entries except for PAE compat guests. */
 #define SHADOW_FOREACH_L2E(_sl2mfn, _sl2e, _gl2p, _done, _dom, _code)       \
 do {                                                                        \
-    int _i;                                                                 \
-    int _xen = !shadow_mode_external(_dom);                                 \
+    unsigned int i_, end_ = SHADOW_L2_PAGETABLE_ENTRIES;                    \
     shadow_l2e_t *_sp = map_domain_page((_sl2mfn));                         \
     ASSERT_VALID_L2(mfn_to_page(_sl2mfn)->u.sh.type);                       \
-    for ( _i = 0; _i < SHADOW_L2_PAGETABLE_ENTRIES; _i++ )                  \
+    if ( !shadow_mode_external(_dom) &&                                     \
+         is_pv_32bit_domain(_dom) &&                                        \
+         mfn_to_page(_sl2mfn)->u.sh.type != SH_type_l2_64_shadow )          \
+        end_ = COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(_dom);                    \
+    for ( i_ = 0; i_ < end_; ++i_ )                                         \
     {                                                                       \
-        if ( (!(_xen))                                                      \
-             || !is_pv_32bit_domain(_dom)                                   \
-             || mfn_to_page(_sl2mfn)->u.sh.type == SH_type_l2_64_shadow     \
-             || (_i < COMPAT_L2_PAGETABLE_FIRST_XEN_SLOT(_dom)) )           \
-        {                                                                   \
-            (_sl2e) = _sp + _i;                                             \
-            if ( shadow_l2e_get_flags(*(_sl2e)) & _PAGE_PRESENT )           \
-                {_code}                                                     \
-            if ( _done ) break;                                             \
-            increment_ptr_to_guest_entry(_gl2p);                            \
-        }                                                                   \
+        (_sl2e) = _sp + i_;                                                 \
+        if ( shadow_l2e_get_flags(*(_sl2e)) & _PAGE_PRESENT )               \
+            { _code }                                                       \
+        if ( _done ) break;                                                 \
+        increment_ptr_to_guest_entry(_gl2p);                                \
     }                                                                       \
     unmap_domain_page(_sp);                                                 \
 } while (0)




 


Rackspace

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