All of lore.kernel.org
 help / color / mirror / Atom feed
* [android-common:android14-kiwi-6.1 0/212] arch/x86/kvm/svm/sev.c:2256:3-19: opportunity for str_enabled_disabled(sev_es_supported)
@ 2026-08-15  4:34 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2026-08-15  4:34 UTC (permalink / raw)
  To: cros-kernel-buildreports; +Cc: oe-kbuild-all

tree:   https://android.googlesource.com/kernel/common android14-kiwi-6.1
head:   88ff6fc3ff2d7717a7cff52af211ca62e0985ac2
commit: 2f7efda53a0a8b462fdd217e732147d7611befe2 [0/212] KVM: SVM: enhance info printk's in SEV init
config: i386-randconfig-051-20260815 (https://download.01.org/0day-ci/archive/20260815/202608151255.MHUMFkbd-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.4.0-5) 12.4.0

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/202608151255.MHUMFkbd-lkp@intel.com/

cocci warnings: (new ones prefixed by >>)
>> arch/x86/kvm/svm/sev.c:2256:3-19: opportunity for str_enabled_disabled(sev_es_supported)
   arch/x86/kvm/svm/sev.c:2252:3-16: opportunity for str_enabled_disabled(sev_supported)

vim +2256 arch/x86/kvm/svm/sev.c

  2164	
  2165	void __init sev_hardware_setup(void)
  2166	{
  2167	#ifdef CONFIG_KVM_AMD_SEV
  2168		unsigned int eax, ebx, ecx, edx, sev_asid_count, sev_es_asid_count;
  2169		bool sev_es_supported = false;
  2170		bool sev_supported = false;
  2171	
  2172		if (!sev_enabled || !npt_enabled)
  2173			goto out;
  2174	
  2175		/*
  2176		 * SEV must obviously be supported in hardware.  Sanity check that the
  2177		 * CPU supports decode assists, which is mandatory for SEV guests to
  2178		 * support instruction emulation.
  2179		 */
  2180		if (!boot_cpu_has(X86_FEATURE_SEV) ||
  2181		    WARN_ON_ONCE(!boot_cpu_has(X86_FEATURE_DECODEASSISTS)))
  2182			goto out;
  2183	
  2184		/* Retrieve SEV CPUID information */
  2185		cpuid(0x8000001f, &eax, &ebx, &ecx, &edx);
  2186	
  2187		/* Set encryption bit location for SEV-ES guests */
  2188		sev_enc_bit = ebx & 0x3f;
  2189	
  2190		/* Maximum number of encrypted guests supported simultaneously */
  2191		max_sev_asid = ecx;
  2192		if (!max_sev_asid)
  2193			goto out;
  2194	
  2195		/* Minimum ASID value that should be used for SEV guest */
  2196		min_sev_asid = edx;
  2197		sev_me_mask = 1UL << (ebx & 0x3f);
  2198	
  2199		/*
  2200		 * Initialize SEV ASID bitmaps. Allocate space for ASID 0 in the bitmap,
  2201		 * even though it's never used, so that the bitmap is indexed by the
  2202		 * actual ASID.
  2203		 */
  2204		nr_asids = max_sev_asid + 1;
  2205		sev_asid_bitmap = bitmap_zalloc(nr_asids, GFP_KERNEL);
  2206		if (!sev_asid_bitmap)
  2207			goto out;
  2208	
  2209		sev_reclaim_asid_bitmap = bitmap_zalloc(nr_asids, GFP_KERNEL);
  2210		if (!sev_reclaim_asid_bitmap) {
  2211			bitmap_free(sev_asid_bitmap);
  2212			sev_asid_bitmap = NULL;
  2213			goto out;
  2214		}
  2215	
  2216		sev_asid_count = max_sev_asid - min_sev_asid + 1;
  2217		if (misc_cg_set_capacity(MISC_CG_RES_SEV, sev_asid_count))
  2218			goto out;
  2219	
  2220		sev_supported = true;
  2221	
  2222		/* SEV-ES support requested? */
  2223		if (!sev_es_enabled)
  2224			goto out;
  2225	
  2226		/*
  2227		 * SEV-ES requires MMIO caching as KVM doesn't have access to the guest
  2228		 * instruction stream, i.e. can't emulate in response to a #NPF and
  2229		 * instead relies on #NPF(RSVD) being reflected into the guest as #VC
  2230		 * (the guest can then do a #VMGEXIT to request MMIO emulation).
  2231		 */
  2232		if (!enable_mmio_caching)
  2233			goto out;
  2234	
  2235		/* Does the CPU support SEV-ES? */
  2236		if (!boot_cpu_has(X86_FEATURE_SEV_ES))
  2237			goto out;
  2238	
  2239		/* Has the system been allocated ASIDs for SEV-ES? */
  2240		if (min_sev_asid == 1)
  2241			goto out;
  2242	
  2243		sev_es_asid_count = min_sev_asid - 1;
  2244		if (misc_cg_set_capacity(MISC_CG_RES_SEV_ES, sev_es_asid_count))
  2245			goto out;
  2246	
  2247		sev_es_supported = true;
  2248	
  2249	out:
  2250		if (boot_cpu_has(X86_FEATURE_SEV))
  2251			pr_info("SEV %s (ASIDs %u - %u)\n",
  2252				sev_supported ? "enabled" : "disabled",
  2253				min_sev_asid, max_sev_asid);
  2254		if (boot_cpu_has(X86_FEATURE_SEV_ES))
  2255			pr_info("SEV-ES %s (ASIDs %u - %u)\n",
> 2256				sev_es_supported ? "enabled" : "disabled",
  2257				min_sev_asid > 1 ? 1 : 0, min_sev_asid - 1);
  2258	
  2259		sev_enabled = sev_supported;
  2260		sev_es_enabled = sev_es_supported;
  2261	#endif
  2262	}
  2263	

--
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:[~2026-08-15  4:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-15  4:34 [android-common:android14-kiwi-6.1 0/212] arch/x86/kvm/svm/sev.c:2256:3-19: opportunity for str_enabled_disabled(sev_es_supported) 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.