All of lore.kernel.org
 help / color / mirror / Atom feed
* [sean-jc:x86/mmu_follow_pfn 86/86] arch/x86/kvm/mmu/spte.c:243:17: error: expected '}' before 'else'
@ 2024-08-15 20:42 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-08-15 20:42 UTC (permalink / raw)
  To: Sean Christopherson; +Cc: oe-kbuild-all

tree:   https://github.com/sean-jc/linux x86/mmu_follow_pfn
head:   611850ae46de0bdd0ae46c81ea4050547fd65346
commit: 611850ae46de0bdd0ae46c81ea4050547fd65346 [86/86] KVM: x86/mmu: Fold all of make_spte()'s writable handling into one if-else
config: i386-randconfig-004-20240815 (https://download.01.org/0day-ci/archive/20240816/202408160457.AF488m7h-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240816/202408160457.AF488m7h-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408160457.AF488m7h-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   arch/x86/kvm/mmu/spte.c: In function 'make_spte':
   arch/x86/kvm/mmu/spte.c:239:19: error: expected expression before '/' token
     239 |                  */
         |                   ^
>> arch/x86/kvm/mmu/spte.c:243:17: error: expected '}' before 'else'
     243 |                 else
         |                 ^~~~
>> arch/x86/kvm/mmu/spte.c:165:14: warning: unused variable 'wrprot' [-Wunused-variable]
     165 |         bool wrprot = false;
         |              ^~~~~~
   arch/x86/kvm/mmu/spte.c: At top level:
>> arch/x86/kvm/mmu/spte.c:248:9: error: expected identifier or '(' before 'if'
     248 |         if (prefetch)
         |         ^~
   In file included from include/asm-generic/bug.h:7,
                    from arch/x86/include/asm/bug.h:87,
                    from include/linux/bug.h:5,
                    from include/linux/alloc_tag.h:8,
                    from include/linux/percpu.h:5,
                    from include/linux/context_tracking_state.h:5,
                    from include/linux/hardirq.h:5,
                    from include/linux/kvm_host.h:7,
                    from arch/x86/kvm/mmu/spte.c:12:
>> include/linux/once_lite.h:27:10: error: expected identifier or '(' before '{' token
      27 |         ({                                                              \
         |          ^
   include/asm-generic/bug.h:152:9: note: in expansion of macro 'DO_ONCE_LITE_IF'
     152 |         DO_ONCE_LITE_IF(condition, WARN, 1, format)
         |         ^~~~~~~~~~~~~~~
   arch/x86/kvm/mmu/spte.c:251:9: note: in expansion of macro 'WARN_ONCE'
     251 |         WARN_ONCE(is_rsvd_spte(&vcpu->arch.mmu->shadow_zero_check, spte, level),
         |         ^~~~~~~~~
   arch/x86/kvm/mmu/spte.c:260:9: error: expected identifier or '(' before 'if'
     260 |         if ((spte & PT_WRITABLE_MASK) && kvm_slot_dirty_track_enabled(slot)) {
         |         ^~
>> arch/x86/kvm/mmu/spte.c:266:9: warning: data definition has no type or storage class
     266 |         *new_spte = spte;
         |         ^
>> arch/x86/kvm/mmu/spte.c:266:10: error: type defaults to 'int' in declaration of 'new_spte' [-Werror=implicit-int]
     266 |         *new_spte = spte;
         |          ^~~~~~~~
>> arch/x86/kvm/mmu/spte.c:266:21: error: 'spte' undeclared here (not in a function)
     266 |         *new_spte = spte;
         |                     ^~~~
>> arch/x86/kvm/mmu/spte.c:267:9: error: expected identifier or '(' before 'return'
     267 |         return wrprot;
         |         ^~~~~~
>> arch/x86/kvm/mmu/spte.c:268:1: error: expected identifier or '(' before '}' token
     268 | }
         | ^
   arch/x86/kvm/mmu/spte.c: In function 'make_spte':
>> arch/x86/kvm/mmu/spte.c:246:9: warning: control reaches end of non-void function [-Wreturn-type]
     246 |         }
         |         ^
   cc1: some warnings being treated as errors


vim +243 arch/x86/kvm/mmu/spte.c

   156	
   157	bool make_spte(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
   158		       const struct kvm_memory_slot *slot,
   159		       unsigned int pte_access, gfn_t gfn, kvm_pfn_t pfn,
   160		       u64 old_spte, bool prefetch, bool can_unsync,
   161		       bool host_writable, u64 *new_spte)
   162	{
   163		int level = sp->role.level;
   164		u64 spte = SPTE_MMU_PRESENT_MASK;
 > 165		bool wrprot = false;
   166	
   167		/*
   168		 * For the EPT case, shadow_present_mask has no RWX bits set if
   169		 * exec-only page table entries are supported.  In that case,
   170		 * ACC_USER_MASK and shadow_user_mask are used to represent
   171		 * read access.  See FNAME(gpte_access) in paging_tmpl.h.
   172		 */
   173		WARN_ON_ONCE((pte_access | shadow_present_mask) == SHADOW_NONPRESENT_VALUE);
   174	
   175		if (sp->role.ad_disabled)
   176			spte |= SPTE_TDP_AD_DISABLED;
   177		else if (kvm_mmu_page_ad_need_write_protect(sp))
   178			spte |= SPTE_TDP_AD_WRPROT_ONLY;
   179	
   180		spte |= shadow_present_mask;
   181		if (!prefetch)
   182			spte |= spte_shadow_accessed_mask(spte);
   183	
   184		/*
   185		 * For simplicity, enforce the NX huge page mitigation even if not
   186		 * strictly necessary.  KVM could ignore the mitigation if paging is
   187		 * disabled in the guest, as the guest doesn't have any page tables to
   188		 * abuse.  But to safely ignore the mitigation, KVM would have to
   189		 * ensure a new MMU is loaded (or all shadow pages zapped) when CR0.PG
   190		 * is toggled on, and that's a net negative for performance when TDP is
   191		 * enabled.  When TDP is disabled, KVM will always switch to a new MMU
   192		 * when CR0.PG is toggled, but leveraging that to ignore the mitigation
   193		 * would tie make_spte() further to vCPU/MMU state, and add complexity
   194		 * just to optimize a mode that is anything but performance critical.
   195		 */
   196		if (level > PG_LEVEL_4K && (pte_access & ACC_EXEC_MASK) &&
   197		    is_nx_huge_page_enabled(vcpu->kvm)) {
   198			pte_access &= ~ACC_EXEC_MASK;
   199		}
   200	
   201		if (pte_access & ACC_EXEC_MASK)
   202			spte |= shadow_x_mask;
   203		else
   204			spte |= shadow_nx_mask;
   205	
   206		if (pte_access & ACC_USER_MASK)
   207			spte |= shadow_user_mask;
   208	
   209		if (level > PG_LEVEL_4K)
   210			spte |= PT_PAGE_SIZE_MASK;
   211	
   212		if (shadow_memtype_mask)
   213			spte |= kvm_x86_call(get_mt_mask)(vcpu, gfn,
   214							  kvm_is_mmio_pfn(pfn));
   215		if (host_writable)
   216			spte |= shadow_host_writable_mask;
   217		else
   218			pte_access &= ~ACC_WRITE_MASK;
   219	
   220		if (shadow_me_value && !kvm_is_mmio_pfn(pfn))
   221			spte |= shadow_me_value;
   222	
   223		spte |= (u64)pfn << PAGE_SHIFT;
   224	
   225		if (pte_access & ACC_WRITE_MASK) {
   226			/*
   227			 * Unsync shadow pages that are reachable by the new, writable
   228			 * SPTE.  Write-protect the SPTE if the page can't be unsync'd,
   229			 * e.g. it's write-tracked (upper-level SPs) or has one or more
   230			 * shadow pages and unsync'ing pages is not allowed.
   231			 *
   232			 * When overwriting an existing leaf SPTE, and the old SPTE was
   233			 * writable, skip trying to unsync shadow pages as any relevant
   234			 * shadow pages must already be unsync, i.e. the hash lookup is
   235			 * unnecessary (and expensive).  Note, this relies on KVM not
   236			 * changing PFNs without first zapping the old SPTE, which is
   237			 * guaranteed by both the shadow MMU and the TDP MMU.
   238			 */
   239			 */
   240			if ((!is_last_spte(old_spte, level) || !is_writable_pte(old_spte)) &&
   241			    mmu_try_to_unsync_pages(vcpu->kvm, slot, gfn, can_unsync, prefetch))
   242				wrprot = true;
 > 243			else
   244				spte |= PT_WRITABLE_MASK | shadow_mmu_writable_mask |
   245					spte_shadow_dirty_mask(spte);
 > 246		}
   247	
 > 248		if (prefetch)
   249			spte = mark_spte_for_access_track(spte);
   250	
   251		WARN_ONCE(is_rsvd_spte(&vcpu->arch.mmu->shadow_zero_check, spte, level),
   252			  "spte = 0x%llx, level = %d, rsvd bits = 0x%llx", spte, level,
   253			  get_rsvd_bits(&vcpu->arch.mmu->shadow_zero_check, spte, level));
   254	
   255		/*
   256		 * Mark the memslot dirty *after* modifying it for access tracking.
   257		 * Unlike folios, memslots can be safely marked dirty out of mmu_lock,
   258		 * i.e. in the fast page fault handler.
   259		 */
   260		if ((spte & PT_WRITABLE_MASK) && kvm_slot_dirty_track_enabled(slot)) {
   261			/* Enforced by kvm_mmu_hugepage_adjust. */
   262			WARN_ON_ONCE(level > PG_LEVEL_4K);
   263			mark_page_dirty_in_slot(vcpu->kvm, slot, gfn);
   264		}
   265	
 > 266		*new_spte = spte;
 > 267		return wrprot;
 > 268	}
   269	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-08-15 20:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-15 20:42 [sean-jc:x86/mmu_follow_pfn 86/86] arch/x86/kvm/mmu/spte.c:243:17: error: expected '}' before 'else' kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.