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

[PATCH 2/2] x86/shadow: adjust 2-level case of SHADOW_FOREACH_L2E()


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Wed, 13 Oct 2021 17:38:36 +0200
  • 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=ukLUF7Im/PJ2Z8SrCJMh3Wvu3vUEqtNNwX8+b+BQm0A=; b=gbchrw8qOtYgi5z8sgjNgo9T21aMoVC4pdJBkVpRZRBMdmDeeBRbCfEx3UoAiOSKshPhAECRqdSMp4ODAgNO3bogrEYj8DxIT6NoWb0TAXrgElwQ3++/vZkejVlwcVVccylPh5IRyAH1Eek16O5NwmQdT4yJohsfltFLFQqvxoe/bSqtLZKu3T2NUw1uHVaw57c8Cns8Fkuz9q3NZXRaD/a4IrYtkQ2ZpjWdkI7eR+zP0iTm/RJcOrqMhL8dumSSbZrH0Ne9H/C5K4YxEviqNO5h1HCoHSMzuiHMrRts33IQ1q/83g0xKoV2RyLq5hOghV3/nZSg6GBLjIdl8h9PUA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ha/w4ryFwYX8WRBRSyWxVH2PsFE8/Chr6ilYGYBn0xGun/M/pvmhaUnYX9JqEryrg2aNN8sZ2owEMpWEFTm00hF/sVB9V7n6Rp6Jw1WisZibqLQsyWq9IE84Bmi5CUGip4iJ8yatEtVrMoWhYFyzPy527DTRIE7q7nNbuotoqIKwud7L9F84E2PJLPVtO1ERrs8Og+yaO29eWaV25wERiGzj3VPbV1DHJ/zliPdAzgBdMIzq+xRBk0gZyd0EITNkIEsDHpXTL0VaZ0r5ZIn8oaVVH1oCvySHdkkluZIvJtJ8F08xv0vH8mF1zBoapXw9+umoL3fPbtN+PTnHjagpCw==
  • Authentication-results: citrix.com; dkim=none (message not signed) header.d=none;citrix.com; 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, 13 Oct 2021 15:38:44 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Coverity apparently takes issue with the assignment inside an if(), but
then only in two of the cases (sh_destroy_l2_shadow() and
sh_unhook_32b_mappings()). As it's pretty simple to break out of the
outer loop without the need for a local helper variable, adjust the code
that way.

While there, with the other "unused value" reports also in mind, further
drop a dead assignment from SHADOW_FOREACH_L1E().

Coverity-ID: 1492857
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---
Looking over other SHADOW_FOREACH_L<N>E() invocations wrt their uses of
"done", I find the audit ones particularly odd: The respective variables
get set only from AUDIT_FAIL() and AUDIT_FAIL_MIN(), but in both cases
after invoking BUG(), i.e. in an unreachable position.

--- a/xen/arch/x86/mm/shadow/multi.c
+++ b/xen/arch/x86/mm/shadow/multi.c
@@ -794,8 +794,7 @@ do {
                          ({ (__done = _done); }), _code);               \
     _sl1mfn = sh_next_page(_sl1mfn);                                    \
     if ( !__done )                                                      \
-        _SHADOW_FOREACH_L1E(_sl1mfn, _sl1e, _gl1p,                      \
-                             ({ (__done = _done); }), _code);           \
+        _SHADOW_FOREACH_L1E(_sl1mfn, _sl1e, _gl1p, _done, _code);       \
 } while (0)
 #else /* Everything else; l1 shadows are only one page */
 #define SHADOW_FOREACH_L1E(_sl1mfn, _sl1e, _gl1p, _done, _code)         \
@@ -808,10 +807,10 @@ do {
 /* 32-bit l2 on PAE/64: four pages, touch every second entry */
 #define SHADOW_FOREACH_L2E(_sl2mfn, _sl2e, _gl2p, _done, _dom, _code)     \
 do {                                                                      \
-    int _i, _j, __done = 0;                                               \
+    int _i, _j;                                                           \
     ASSERT(shadow_mode_external(_dom));                                   \
     ASSERT(mfn_to_page(_sl2mfn)->u.sh.type == SH_type_l2_32_shadow);      \
-    for ( _j = 0; _j < 4 && !__done; _j++ )                               \
+    for ( _j = 0; _j < 4; _j++ )                                          \
     {                                                                     \
         shadow_l2e_t *_sp = map_domain_page(_sl2mfn);                     \
         for ( _i = 0; _i < SHADOW_L2_PAGETABLE_ENTRIES; _i += 2 )         \
@@ -819,11 +818,12 @@ do {
             (_sl2e) = _sp + _i;                                           \
             if ( shadow_l2e_get_flags(*(_sl2e)) & _PAGE_PRESENT )         \
                 {_code}                                                   \
-            if ( (__done = (_done)) ) break;                              \
+            if ( _done ) break;                                           \
             increment_ptr_to_guest_entry(_gl2p);                          \
         }                                                                 \
         unmap_domain_page(_sp);                                           \
         if ( _j < 3 ) _sl2mfn = sh_next_page(_sl2mfn);                    \
+        if ( _i < SHADOW_L2_PAGETABLE_ENTRIES ) break;                    \
     }                                                                     \
 } while (0)
 




 


Rackspace

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