From: kernel test robot <lkp@intel.com>
To: cros-kernel-buildreports@googlegroups.com
Cc: oe-kbuild-all@lists.linux.dev
Subject: [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)
Date: Sat, 15 Aug 2026 12:34:03 +0800 [thread overview]
Message-ID: <202608151255.MHUMFkbd-lkp@intel.com> (raw)
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
reply other threads:[~2026-08-15 4:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202608151255.MHUMFkbd-lkp@intel.com \
--to=lkp@intel.com \
--cc=cros-kernel-buildreports@googlegroups.com \
--cc=oe-kbuild-all@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.