From nobody Thu Dec 18 09:59:22 2025 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 515101F8EF2 for ; Mon, 13 Jan 2025 22:27:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736807265; cv=none; b=GAd5EAd/PbooekSbnx/9XE9d8dFNBwI+Eqz3D1UrDBUbO9BvoBK+5bdg97/J0fy1M61otBq4B8DD3ZrT5pdK6HK+ODk+OAqQpNAhgKFzqG1eoPDqaJAapMczOkGq1M/lQG0YrluXVuSb+3ITKwfF6mpJUFb5167z772IiXEayAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736807265; c=relaxed/simple; bh=vblzX9oZHAXxiqXhSe7IP/dcd0L4gup1FWh8NLr+JyY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=n8VQWj10ilJppAi2N6itPnu4ykaRB34WUQSWIUyjKZWgivZt/EhGXJZl6SM+VR2vHntxs+oo6szafBz2VO/yXXetzpTClS+3pCCVJ3mB4BCcB73KdXErUSS+vL99KmnukoGDk6J5AnpF2MADdsJFI4h0m/tOHSq7PNVQkOIV2zc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=1zI/CGE8; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="1zI/CGE8" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-21648c8601cso78317505ad.2 for ; Mon, 13 Jan 2025 14:27:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736807264; x=1737412064; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=FedWRlmic2iRbfD7jbI+6doHjrw5hxRZcg5PhzQ2p6Y=; b=1zI/CGE84arHGyuQdpAnpAG8T8e0GBfHnhAGsyG7oTIB86Chtqu4VOmSurNpvcOB+u mkeIYdL1nTN20ehmFckI5gky5Szijdi4jxF45xycc0TRvVMDYf7a/DaeLXWtKyi1pxns LEd7pwtRstsOuuAqq8KzduiHaV9ZjMoy/8MW2vYCzTb+VFGdPhfweePJNCEF/Ll0Ilgq RvzneqiH7vtBz5wWq3KsMCWKA+EhBNJM76DscIqheqokUy4hA1EsyXRVWc4QdYMZKqn5 s+tHTVk1NIOPd90n7gH8bLltNUcBK25bzINrBXq2EtQ9l5wlSftcJGF8x/SV43xVggWQ k3xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736807264; x=1737412064; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FedWRlmic2iRbfD7jbI+6doHjrw5hxRZcg5PhzQ2p6Y=; b=lDsoi/BBMqc9GmO56th6afYdJmCsxAuQvnSxLyN0UIsnSG618GHT0QG/GFoENr6tXC hFIVOLrS1wNqu7tbSO7/yak8Hwg35N9Qi6b6htJUsDjEzwlpHQsL2d+R4gsLlsHoJhTF MBe6VJjq45eVK45F1DD5ZxIAue6JaHPjjw3VNg/abyFbFKZpKRky+mjCNzSDCERDo3Lv T/JHVn9R7bmm1y5/ZQaVLPB+z7+u69GJqrj7WJoZUBxyv+my8HjfsiY1bHLTLiR5fPXg 3UkPJ8p0ajI7037poWqKcMM5Jqw5FQ5MHYNeU+Z9TbExTHqtvo83NkznE2Fwi/xdPtxN 7rmA== X-Forwarded-Encrypted: i=1; AJvYcCVNm0NnYTBD6xMlibjo/S1tQ9ehAxQLj28Op8vVv1/uILxV4EhU35LfsGfjis/F+WU11mnHDz4MWTgYBmI=@vger.kernel.org X-Gm-Message-State: AOJu0YwhNscpFGrjTT60de+EDDDtD5rtL95kezsFN0QfQ6+VMFQWylu4 4sq/PNHHj00zGvvDESBrZzWzt3DAAWBRiFUMxjhfbxBipcImXU3vqNfxzalnkvzvd1AxMx12d6B 2Fw== X-Google-Smtp-Source: AGHT+IG/ROPkD8yLMtzQiIrh1R/MPmPtvI4UCtDnjy6mbuSklnLOxfXbAF79flfOKNZCBDDB0j65jdsuvK8= X-Received: from plsd19.prod.google.com ([2002:a17:902:b713:b0:212:4fad:1dc1]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:f705:b0:205:4721:19c with SMTP id d9443c01a7336-21a83fe48fdmr325122105ad.37.1736807263732; Mon, 13 Jan 2025 14:27:43 -0800 (PST) Reply-To: Sean Christopherson Date: Mon, 13 Jan 2025 14:27:36 -0800 In-Reply-To: <20250113222740.1481934-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250113222740.1481934-1-seanjc@google.com> X-Mailer: git-send-email 2.47.1.688.g23fc6f90ad-goog Message-ID: <20250113222740.1481934-2-seanjc@google.com> Subject: [PATCH 1/5] KVM: x86: Reject Hyper-V's SEND_IPI hypercalls if local APIC isn't in-kernel From: Sean Christopherson To: Vitaly Kuznetsov , Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Dongjie Zou , stable@vger.kernel Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Advertise support for Hyper-V's SEND_IPI and SEND_IPI_EX hypercalls if and only if the local API is emulated/virtualized by KVM, and explicitly reject said hypercalls if the local APIC is emulated in userspace, i.e. don't rely on userspace to opt-in to KVM_CAP_HYPERV_ENFORCE_CPUID. Rejecting SEND_IPI and SEND_IPI_EX fixes a NULL-pointer dereference if Hyper-V enlightenments are exposed to the guest without an in-kernel local APIC: dump_stack+0xbe/0xfd __kasan_report.cold+0x34/0x84 kasan_report+0x3a/0x50 __apic_accept_irq+0x3a/0x5c0 kvm_hv_send_ipi.isra.0+0x34e/0x820 kvm_hv_hypercall+0x8d9/0x9d0 kvm_emulate_hypercall+0x506/0x7e0 __vmx_handle_exit+0x283/0xb60 vmx_handle_exit+0x1d/0xd0 vcpu_enter_guest+0x16b0/0x24c0 vcpu_run+0xc0/0x550 kvm_arch_vcpu_ioctl_run+0x170/0x6d0 kvm_vcpu_ioctl+0x413/0xb20 __se_sys_ioctl+0x111/0x160 do_syscal1_64+0x30/0x40 entry_SYSCALL_64_after_hwframe+0x67/0xd1 Note, checking the sending vCPU is sufficient, as the per-VM irqchip_mode can't be modified after vCPUs are created, i.e. if one vCPU has an in-kernel local APIC, then all vCPUs have an in-kernel local APIC. Reported-by: Dongjie Zou Fixes: 214ff83d4473 ("KVM: x86: hyperv: implement PV IPI send hypercalls") Fixes: 2bc39970e932 ("x86/kvm/hyper-v: Introduce KVM_GET_SUPPORTED_HV_CPUID= ") Cc: stable@vger.kernel Signed-off-by: Sean Christopherson Reviewed-by: Vitaly Kuznetsov --- arch/x86/kvm/hyperv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 4f0a94346d00..44c88537448c 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -2226,6 +2226,9 @@ static u64 kvm_hv_send_ipi(struct kvm_vcpu *vcpu, str= uct kvm_hv_hcall *hc) u32 vector; bool all_cpus; =20 + if (!lapic_in_kernel(vcpu)) + return HV_STATUS_INVALID_HYPERCALL_INPUT; + if (hc->code =3D=3D HVCALL_SEND_IPI) { if (!hc->fast) { if (unlikely(kvm_read_guest(kvm, hc->ingpa, &send_ipi, @@ -2852,7 +2855,8 @@ int kvm_get_hv_cpuid(struct kvm_vcpu *vcpu, struct kv= m_cpuid2 *cpuid, ent->eax |=3D HV_X64_REMOTE_TLB_FLUSH_RECOMMENDED; ent->eax |=3D HV_X64_APIC_ACCESS_RECOMMENDED; ent->eax |=3D HV_X64_RELAXED_TIMING_RECOMMENDED; - ent->eax |=3D HV_X64_CLUSTER_IPI_RECOMMENDED; + if (!vcpu || lapic_in_kernel(vcpu)) + ent->eax |=3D HV_X64_CLUSTER_IPI_RECOMMENDED; ent->eax |=3D HV_X64_EX_PROCESSOR_MASKS_RECOMMENDED; if (evmcs_ver) ent->eax |=3D HV_X64_ENLIGHTENED_VMCS_RECOMMENDED; --=20 2.47.1.688.g23fc6f90ad-goog From nobody Thu Dec 18 09:59:22 2025 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2BDAC1F9EBA for ; Mon, 13 Jan 2025 22:27:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736807267; cv=none; b=Bk94vRQDxiFCG+vmpj51pnljVC2+txBtiY1ma1Di8JtI/XQZDYGyHWc+G53lj3WdFnuexNXNbpeQ+P12gS8TFbTGnjnN1qoJFDNXc0q0vCO4D+/J99D7FReso9APipF4TTjYxHRh6lXBSfHBdFO6VFuiTrxM76PXCnVE1544EvQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736807267; c=relaxed/simple; bh=zqLBBXrug8v32oNQce0fAdA/PWXxsTOVhZ1W2PAUujg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Hyhe16ZVJzsYHAbuQHWr4A9TtvH5VjHAz1aaRURuAr0npx4m5t1fLhVZfib+m2EoKZMwF5/aoUWH53IMhSO+/5RChbHrA8qEgq+1oemiiXdcB+p91s0Ix3qu1Y0/T4sAF5apKu21fT+47UMo8UKom7eZ8IpOTEniqEriYshGfq0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=fq58RQRH; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="fq58RQRH" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-2167141e00eso84967955ad.2 for ; Mon, 13 Jan 2025 14:27:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736807265; x=1737412065; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=lOOaItQ8XjWrN4V+XnxPKIJp+wwpgWIYOMyymj/eGI4=; b=fq58RQRHVE7B25bcyzIUnGkKtG6O8D3+vBcC0+PWEwNE1fBg/cmE48lOcTxLVSysD6 zS/PeK6zoPkY4WyXcuNqyXva+vlDRHVdHGAw7NzKZrG2o5oAgK5NJESfTJ+rzk2eQcUG fhZ+eLw8PYdhfuSq0A/qn4M3nHVzA19Afwm+bY9StQNKtiTJpNQzheQJBPA0ETsuVCLX 6qS82tiHEN4C2hNqsERJWnQpm0v41ga+V+qFo8Ry8HA5vvV4/jETZayLjODvQGitXrhV i1dTTc7pHcYeC00xwL2YevBxtqfdf+IH8dHsqKhHGE37ka7tcDy4aVexMkSmANtHjemQ +VGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736807265; x=1737412065; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lOOaItQ8XjWrN4V+XnxPKIJp+wwpgWIYOMyymj/eGI4=; b=uQJGGnqcDqGYprF9+un+i1Mzpf+dn/kVtdDFxQeuBrI+pm/9bT4R6sdHbnAhf+5dHX 0bM8Ib65ZpliXntlmyh9GVsSY6+5jkIq8Nccvzzpqmhqd+R/QW/iJy/lsws8BLjALWNs Hh2QlvwYrWyYlz49c2rLj/TNk62ZE2FQ1EZBuIF9W5PjlS4bEi7bV/cvRPXkcLIr4RHv hhQx43egNTeMiruTOP4TDBwtwdVEOVqB1NRp5/DYbz1zrYQSZQ43YcR+CfHg3rOLcd3I foW7rn7GleOdxRjZgJQI9o1V7e0crgFrRCzaSr9v4XgGGHw+NEXRF+ZTsfbUHyM7z5Gq 631g== X-Forwarded-Encrypted: i=1; AJvYcCW3qzJ4Ok7n1MNbbul6g5AWbBfiKcMbdHeOWPb+Ay/h1U/nmTRu7YdO5YpEV4Qn8fEBXJ8Ft8UJmMK8F+Q=@vger.kernel.org X-Gm-Message-State: AOJu0Yx34OR54q52ilvHg3ml/bCOFJYPPdc4OUmnw2xwSWx9NHFlzchP ad6diHFw2tTYqKgBeggulL3Qh/7K3Ejg1ShuRVoiuNDPlS4pLBjZFDqI3MxTLUpKtahHnuC1C5i N3A== X-Google-Smtp-Source: AGHT+IE4SCIj0eT4MwfhXXuqwjQSQynoe//BaCPOdrBHH5GyAIKrqtS2BvL94oyZ9JQHJxJWpwkBjqq4Xkc= X-Received: from pfbcz13.prod.google.com ([2002:aa7:930d:0:b0:724:f17d:ebd7]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:8cc3:b0:1d9:2b51:3ccd with SMTP id adf61e73a8af0-1e88cf7ba29mr37755024637.7.1736807265389; Mon, 13 Jan 2025 14:27:45 -0800 (PST) Reply-To: Sean Christopherson Date: Mon, 13 Jan 2025 14:27:37 -0800 In-Reply-To: <20250113222740.1481934-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250113222740.1481934-1-seanjc@google.com> X-Mailer: git-send-email 2.47.1.688.g23fc6f90ad-goog Message-ID: <20250113222740.1481934-3-seanjc@google.com> Subject: [PATCH 2/5] KVM: selftests: Mark test_hv_cpuid_e2big() static in Hyper-V CPUID test From: Sean Christopherson To: Vitaly Kuznetsov , Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Dongjie Zou , stable@vger.kernel Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Make the Hyper-V CPUID test's local helper test_hv_cpuid_e2big() static, it's not used outside of the test (and isn't intended to be). Cc: Vitaly Kuznetsov Signed-off-by: Sean Christopherson Reviewed-by: Vitaly Kuznetsov --- tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c b/tools/test= ing/selftests/kvm/x86_64/hyperv_cpuid.c index 4f5881d4ef66..9a0fcc713350 100644 --- a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c +++ b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c @@ -111,7 +111,7 @@ static void test_hv_cpuid(const struct kvm_cpuid2 *hv_c= puid_entries, } } =20 -void test_hv_cpuid_e2big(struct kvm_vm *vm, struct kvm_vcpu *vcpu) +static void test_hv_cpuid_e2big(struct kvm_vm *vm, struct kvm_vcpu *vcpu) { static struct kvm_cpuid2 cpuid =3D {.nent =3D 0}; int ret; --=20 2.47.1.688.g23fc6f90ad-goog From nobody Thu Dec 18 09:59:22 2025 Received: from mail-pl1-f202.google.com (mail-pl1-f202.google.com [209.85.214.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2AD91F9F7C for ; Mon, 13 Jan 2025 22:27:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736807269; cv=none; b=sxuxrnQ38M03MGXbRdDxeMQmyI3WSxX8/ztgaq6ig08Us/mXyxtqBpiL/FMxSu4N+gJXjTW33+CkiQqxOXgsLrM+rj/DLgS8j8SvRD1a633uxvScuPM3NK13+E9Qrl5lOsXRM/+SE1wbX3LEDN19uPPL0mMvxs7I3R89g5oVYdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736807269; c=relaxed/simple; bh=5GjPFjMPTzjbvv9jMn0Vu+JcFADgwPVyHZSXDMV12jA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=DMJMULwR9D8LueCwj3Zsxv45YhhLQCYaWbgIQAsIkhLYymyCPWJHFSE7MlEhVPs7EPXsjIpI3n5uRN419B6DhPk/DZRkcAD06hE+G5qBC2qqmxQPGplwLlzWahfpzMBDS8kY9oV/CloeNE87tbI2pyKlbm8XbhOvzz4pas6EVY8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=T13yTbse; arc=none smtp.client-ip=209.85.214.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="T13yTbse" Received: by mail-pl1-f202.google.com with SMTP id d9443c01a7336-21661949f23so140517715ad.3 for ; Mon, 13 Jan 2025 14:27:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736807267; x=1737412067; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=39mnKX1L0qcb+XQar8pyjjef/DCqBo7Lr0CV2YNY9CI=; b=T13yTbseqeQAH5KEPiugc/exWyyjEyGMweAohAw+s5JWB7yfjYpo9vUZIcEqbpKJKl bcbfTbAAzipDmq1blXRBtSeYqAPIh671M7t7WBzQ3ourEkpQlmnHnychm7aXNqOvW4+z fA5f9/nU0GQGhlAhU7j4tnEgqL/CbIIPgkNkEVooR7emBvR9wlY9X22gNaa7Zeg36nF4 +zBLLiVemGOQDNo0tWongkdcDVOAyes3OdnkF+yIYHT0cEj+RoQfBSU3lvVCL7oYd77J 9MpXjMcN8nsbHzrHY/Jw12mOUVsJ6yUi+Mr2hP70XAZZjOsGnlIztsZwG8zp/Ovz4R7k T9lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736807267; x=1737412067; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=39mnKX1L0qcb+XQar8pyjjef/DCqBo7Lr0CV2YNY9CI=; b=Yqs4AKawrPVwwGlmk9gd/1ZhudpLk3dxkRUrcp4PGgUVA9w5yH/09xUcOF+GAFss7k xLHlahOc1tHMR1cdjm9zoQEJHF66c7hkaYUqwNWclnCPo9UGzByJHua7/u429WUsi7Rd f3NTrHz4LOra9AwiIgUzzu0dbVcwxKrQRmicLjGNe3rKDed59wOJ8z01fx2vhY5sRa2M gEy/4JBSsMYr0dJOjKDvto8k8clS8+sp/Y1sJDuQOm9ZNrOx2QivM37SugwvdONqgXkR Ta+Wo7B5O/Ax8Cd4iV9A0qbGJhn5pyJYIWIpUhLgm7Fo1yDE+kMc0KWDNxHZ56/HfpZ3 wcEw== X-Forwarded-Encrypted: i=1; AJvYcCUcoVbPsry5MjywmBvl2z1165q+UjjfNFZB10fAqfHCndEdF/FPdp7za5RD9ghSBbgE4fjo5gO012ywUMg=@vger.kernel.org X-Gm-Message-State: AOJu0Yx3z5PIkHAt/ZByY+X0WGxGnepHvx/AVg01TGpAyplnW9XOnmRY 0MvRKoyDc8i2A7ekVa1OD/hCOVE3Vs1tq6LfdfwgJHLbZ8zMlGDEw+F1ltpJAAPChMGkQQNoh0y y8A== X-Google-Smtp-Source: AGHT+IHpFJQ9BF+w23kswjBN8A1uwfUDYhkyBhOqmPuMktb7ZLvC/8lkvUR8KHuk272+C/dk8xx6cgvyp/g= X-Received: from plks12.prod.google.com ([2002:a17:903:2cc:b0:211:fb3b:763b]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:c941:b0:215:a179:14ca with SMTP id d9443c01a7336-21a83f3eec9mr341082645ad.2.1736807267148; Mon, 13 Jan 2025 14:27:47 -0800 (PST) Reply-To: Sean Christopherson Date: Mon, 13 Jan 2025 14:27:38 -0800 In-Reply-To: <20250113222740.1481934-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250113222740.1481934-1-seanjc@google.com> X-Mailer: git-send-email 2.47.1.688.g23fc6f90ad-goog Message-ID: <20250113222740.1481934-4-seanjc@google.com> Subject: [PATCH 3/5] KVM: selftests: Explicitly free CPUID array at end of Hyper-V CPUID test From: Sean Christopherson To: Vitaly Kuznetsov , Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Dongjie Zou , stable@vger.kernel Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Explicitly free the array of CPUID entries at the end of the Hyper-V CPUID test, mainly in anticipation of moving management of the array into the main test helper. Cc: Vitaly Kuznetsov Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c b/tools/test= ing/selftests/kvm/x86_64/hyperv_cpuid.c index 9a0fcc713350..09f9874d7705 100644 --- a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c +++ b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c @@ -164,6 +164,7 @@ int main(int argc, char *argv[]) =20 hv_cpuid_entries =3D kvm_get_supported_hv_cpuid(); test_hv_cpuid(hv_cpuid_entries, kvm_cpu_has(X86_FEATURE_VMX)); + free((void *)hv_cpuid_entries); =20 out: kvm_vm_free(vm); --=20 2.47.1.688.g23fc6f90ad-goog From nobody Thu Dec 18 09:59:22 2025 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A3441FA16B for ; Mon, 13 Jan 2025 22:27:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736807270; cv=none; b=Loyf2ystmV+ZW4jqxaSrybYfZp/BcIoCJ9ni3eF5ivh8/hEiNOx9k58zdU/b+b7UxXdSPIMMF7kJTH8YbOraKwt5gsrWpY6dajKPDTkulWYM6hxlY7zSTj/xxLaPhycJIQ7Lwi2S8RdJaeAJYdzxc+Ur9R/8cKoJ+c2KcMPGVgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736807270; c=relaxed/simple; bh=iZqIiGhqGkDp1l9h+Tl36RWsA0eh5huy0GX52g1XNG8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=mFncItMwXcX7quVV4fjCu/1xq1tzLVFc1gL6ktzOHsTq6vEeVF07W7HOidCibs8LrjPU15mMwtTA2XEE3YvXRjP5NIB4yml0cy6Ons9bLl4p7fVLflxhesWWIS23wIkQ97WQUr0TaP3KUIPYSGUNzFwkhDZXU/xaViOqaXzqKww= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=TuVVz5Bh; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TuVVz5Bh" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2ef91d5c863so8610560a91.2 for ; Mon, 13 Jan 2025 14:27:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736807268; x=1737412068; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=BUiKBnRthtYi8hLYA5ryBjgwDDiPDiUap44/jYe6tjY=; b=TuVVz5Bhx0l2kiKirn3JkyekrSyaOSV6MR5UgfkqoIEg0lbDs8LEUfqR5pB9qXS2bp L90zeE0ir9NlvnXwiYAIfM1Svghro3L+TNFjx05e3tvXSQ8fKzcFoUUIcQkayIK0OlEZ DZOj1CXSi0mKZpwNkJhIhcLknl4e9p4+6wuGAbXUcE/PyBOcYOQhWkwdZmcFlOnqv4rt GpEruq7xhcTw4pv1k0RKBEy4eVf70h8Gt3x73HWGpEUI6n3m7jBvc1tAwFn2HjXVTBOo 4B2EjH2u0AVNaEd+W1CPf7/AkKynQFEYw9sS/RakU1nXj4rQyULGA8bl/pQax4ECHETa LN1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736807268; x=1737412068; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BUiKBnRthtYi8hLYA5ryBjgwDDiPDiUap44/jYe6tjY=; b=V8Mn7jrUH2HW6DqXkRO4i7G59XQ8GrHFZijDE+0i1aTSa2GpuiGK7DlAPz2sHSj05g 4nqNaZ8zlKODP9gthbvxk050yCu9cB3j4hF9GoSBt6wd98DWcBj4LXeex1uwPzqUJcs8 s2+DFaMm7ppSGEQH7bC3sR3XWqaUVp8Ue3b5loM1kD5IoCxgGz/hke/pI3Ph92D5pm1p WxECN509bBR3RF/LfjAr+Ntxxigowg4Ie5L5o++XsEwJgqV3bdWcmlN+lf4mi1wncSM8 JiGM2NSOjPnqM2SY1Zf/cooExbHIr+ylOFu1rntYBND7FrIKRRJUVakijvx+H9EJY+wM OXlA== X-Forwarded-Encrypted: i=1; AJvYcCUF+m4aiWsU3ztWZrIMROcAPyzrbjnQBPHIifRqtoS1v0gZW0vuJ8wvUeS4ZURTI3v/RfTM1CjpQ8xth34=@vger.kernel.org X-Gm-Message-State: AOJu0YzRMtelgoT4AgFsYQMnzin68F99Hn4jG7G7OXR/aBh2YlORxWbS 3XYUOFY+zkLO2LcpBaiNE4wc2YKiGjUKX3rV+WlIqWjUdtDtwHEXss+qgWaGMTzcwcqwP7xQcvu QWg== X-Google-Smtp-Source: AGHT+IHr3YxVY4T6srwZUwxI0ZW6g2YPlW69vv/o0vnwcKqZpomk75DDB0odCx5hUB1kSCPXFWYmf+EoR1o= X-Received: from pjbsd14.prod.google.com ([2002:a17:90b:514e:b0:2ea:5613:4d5d]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:2588:b0:2ee:c9b6:c26a with SMTP id 98e67ed59e1d1-2f548eae05amr33135273a91.11.1736807268726; Mon, 13 Jan 2025 14:27:48 -0800 (PST) Reply-To: Sean Christopherson Date: Mon, 13 Jan 2025 14:27:39 -0800 In-Reply-To: <20250113222740.1481934-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250113222740.1481934-1-seanjc@google.com> X-Mailer: git-send-email 2.47.1.688.g23fc6f90ad-goog Message-ID: <20250113222740.1481934-5-seanjc@google.com> Subject: [PATCH 4/5] KVM: selftests: Manage CPUID array in Hyper-V CPUID test's core helper From: Sean Christopherson To: Vitaly Kuznetsov , Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Dongjie Zou , stable@vger.kernel Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allocate, get, and free the CPUID array in the Hyper-V CPUID test in the test's core helper, instead of copy+pasting code at each call site. In addition to deduplicating a small amount of code, restricting visibility of the array to a single invocation of the core test prevents "leaking" an array across test cases. Passing in @vcpu to the helper will also allow pivoting on VM-scoped information without needing to pass more booleans, e.g. to conditionally assert on features that require an in-kernel APIC. Cc: Vitaly Kuznetsov Signed-off-by: Sean Christopherson --- .../selftests/kvm/x86_64/hyperv_cpuid.c | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c b/tools/test= ing/selftests/kvm/x86_64/hyperv_cpuid.c index 09f9874d7705..90c44765d584 100644 --- a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c +++ b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c @@ -41,13 +41,18 @@ static bool smt_possible(void) return res; } =20 -static void test_hv_cpuid(const struct kvm_cpuid2 *hv_cpuid_entries, - bool evmcs_expected) +static void test_hv_cpuid(struct kvm_vcpu *vcpu, bool evmcs_expected) { + const struct kvm_cpuid2 *hv_cpuid_entries; int i; int nent_expected =3D 10; u32 test_val; =20 + if (vcpu) + hv_cpuid_entries =3D vcpu_get_supported_hv_cpuid(vcpu); + else + hv_cpuid_entries =3D kvm_get_supported_hv_cpuid(); + TEST_ASSERT(hv_cpuid_entries->nent =3D=3D nent_expected, "KVM_GET_SUPPORTED_HV_CPUID should return %d entries" " (returned %d)", @@ -109,6 +114,7 @@ static void test_hv_cpuid(const struct kvm_cpuid2 *hv_c= puid_entries, * entry->edx); */ } + free((void *)hv_cpuid_entries); } =20 static void test_hv_cpuid_e2big(struct kvm_vm *vm, struct kvm_vcpu *vcpu) @@ -129,7 +135,6 @@ static void test_hv_cpuid_e2big(struct kvm_vm *vm, stru= ct kvm_vcpu *vcpu) int main(int argc, char *argv[]) { struct kvm_vm *vm; - const struct kvm_cpuid2 *hv_cpuid_entries; struct kvm_vcpu *vcpu; =20 TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_CPUID)); @@ -138,10 +143,7 @@ int main(int argc, char *argv[]) =20 /* Test vCPU ioctl version */ test_hv_cpuid_e2big(vm, vcpu); - - hv_cpuid_entries =3D vcpu_get_supported_hv_cpuid(vcpu); - test_hv_cpuid(hv_cpuid_entries, false); - free((void *)hv_cpuid_entries); + test_hv_cpuid(vcpu, false); =20 if (!kvm_cpu_has(X86_FEATURE_VMX) || !kvm_has_cap(KVM_CAP_HYPERV_ENLIGHTENED_VMCS)) { @@ -149,9 +151,7 @@ int main(int argc, char *argv[]) goto do_sys; } vcpu_enable_evmcs(vcpu); - hv_cpuid_entries =3D vcpu_get_supported_hv_cpuid(vcpu); - test_hv_cpuid(hv_cpuid_entries, true); - free((void *)hv_cpuid_entries); + test_hv_cpuid(vcpu, true); =20 do_sys: /* Test system ioctl version */ @@ -161,10 +161,7 @@ int main(int argc, char *argv[]) } =20 test_hv_cpuid_e2big(vm, NULL); - - hv_cpuid_entries =3D kvm_get_supported_hv_cpuid(); - test_hv_cpuid(hv_cpuid_entries, kvm_cpu_has(X86_FEATURE_VMX)); - free((void *)hv_cpuid_entries); + test_hv_cpuid(NULL, kvm_cpu_has(X86_FEATURE_VMX)); =20 out: kvm_vm_free(vm); --=20 2.47.1.688.g23fc6f90ad-goog From nobody Thu Dec 18 09:59:22 2025 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 039D21FA8C6 for ; Mon, 13 Jan 2025 22:27:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736807272; cv=none; b=jONdZiSxI4+Vd/xtDr218pM5FViIdiRQeOYesr3Xs0OQ/f7kZpEmaJBG+FvC0dNMR9h8WeCzFEoDeF0PuXYSXnHwhWyxuvxcY7eAAzpc7GPw85GkqB0oXflkyKfy4+ZhTaS109iT5aGbxWIafifpV4zwjCxXSnB7UMTftrJJP4o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736807272; c=relaxed/simple; bh=rVO7MBo0ZRsY1HA2eYCKrFCp2627yEJRpTuMc9vzE00=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=QabEs9HSoXc9bVYBeYWOcliF0rAiHS+yEC16/vRZTFVV/gHHJjZ0WN2VDSju2IX37lDjZyVwHYLxs018qWjIbd1fY+PjSshXNoykf9yBhgq/LrpgOxgQwIko7n+u2rO46GQ1becp0/bK07CPsrh38IM69L5UJYPbVzIpvpQE97k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=WJI5KfBS; arc=none smtp.client-ip=209.85.216.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="WJI5KfBS" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-2ef9b9981f1so12521728a91.3 for ; Mon, 13 Jan 2025 14:27:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736807270; x=1737412070; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=jEclE4N/e4eNENlrwuP3qv7v6wm9foEArsL1tPTX0Ls=; b=WJI5KfBS5lcAQbkxHWvNHdz1qnITUV+sk5jbHKFTHW/xPQhdqsK/VtepuTQQjPHMkP cAodJnp83YHRKKOvBSG9iGGojEV/h0jeAXotGm8+wKYbt+n7o5sTgGXnJ0/84Ii3KV1O MYy4qLh2K339/MZaWBHuUUsfw/MAMLEhvu137howCi38fiNAzSdwi3AEu6JJevxLEDqO +OkJIeUpEQQ6O7s6yGQtQtljZk2mrfDbusq5YhNpnJ9aZntCrKd/acEj0sd/Q/YXaYMp 2hLuomNrbBvUdZrpLE0xhcgfc5pFbhphOybTHwWOaVfMm42yBejqnR0aomlEzEp3breW NAmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736807270; x=1737412070; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=jEclE4N/e4eNENlrwuP3qv7v6wm9foEArsL1tPTX0Ls=; b=fv+9+FVp27j6SDhE4TdU3AYRbSVLbS6pCwJanJ3t9VwaUEm02X9b0df7zsy0NwzTZl Vy7rxMTFrgbjrreDvj130/jyYfv5pCn9iEg2EJMQQPtSjLya43oW3xOlQsTeEOYPbarm o2ivZ8Jt/1A3Cv47CLV0QO3XaAEJZoZMQEF0FFjbivhZM950hYJOesWLMJfRWJzSZZlw zb5iuoxMEvN2SGJYbH1cesn+S1LoveU/b96U49t06ShBlZpagGXPQm5RaC7n9GU9DG/r itA1G8YDOiq+QlKt9Kvb3xbZn0ZUMT9aaiAtAlHkzbvQKTT76lLt4oLMNHcdkJ587s/Z oe4g== X-Forwarded-Encrypted: i=1; AJvYcCVF+EpQGPhl4x3JmP0f4zwjNs0mc51ALnm3lk1tCalK17Ati4fAaRYK9BkDyItIHdUJ3oddZjWGGhRuTTY=@vger.kernel.org X-Gm-Message-State: AOJu0YwdF1miGCIr1aH3tzMD3aGYC3cErUtIA6h6kIoPa5qPUpojz/uq niRwpjlZ9Il6qDuI9bn7mk8zLOYNUTUXLJ3xCLSrUdwU+4Sz6s0okZZJG+cvOoXDG3yMscKJvCz 4kg== X-Google-Smtp-Source: AGHT+IFiLFKOYHUapcng1sIBy0z/SlnfN8YnWN43Y6s4+aq1QD/w0XiZiCqkv3J1FCAtlMyUn3VklWhmgG4= X-Received: from pjbov7.prod.google.com ([2002:a17:90b:2587:b0:2f4:3e59:8bb1]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:53c7:b0:2ee:9e06:7db0 with SMTP id 98e67ed59e1d1-2f548f3400fmr33844299a91.11.1736807270414; Mon, 13 Jan 2025 14:27:50 -0800 (PST) Reply-To: Sean Christopherson Date: Mon, 13 Jan 2025 14:27:40 -0800 In-Reply-To: <20250113222740.1481934-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250113222740.1481934-1-seanjc@google.com> X-Mailer: git-send-email 2.47.1.688.g23fc6f90ad-goog Message-ID: <20250113222740.1481934-6-seanjc@google.com> Subject: [PATCH 5/5] KVM: selftests: Add CPUID tests for Hyper-V features that need in-kernel APIC From: Sean Christopherson To: Vitaly Kuznetsov , Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Dongjie Zou , stable@vger.kernel Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add testcases to x86's Hyper-V CPUID test to verify that KVM advertises support for features that require an in-kernel local APIC appropriately, i.e. that KVM hides support from the vCPU-scoped ioctl if the VM doesn't have an in-kernel local APIC. Cc: Vitaly Kuznetsov Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c b/tools/test= ing/selftests/kvm/x86_64/hyperv_cpuid.c index 90c44765d584..f76b6a95b530 100644 --- a/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c +++ b/tools/testing/selftests/kvm/x86_64/hyperv_cpuid.c @@ -43,6 +43,7 @@ static bool smt_possible(void) =20 static void test_hv_cpuid(struct kvm_vcpu *vcpu, bool evmcs_expected) { + const bool has_irqchip =3D !vcpu || vcpu->vm->has_irqchip; const struct kvm_cpuid2 *hv_cpuid_entries; int i; int nent_expected =3D 10; @@ -85,12 +86,19 @@ static void test_hv_cpuid(struct kvm_vcpu *vcpu, bool e= vmcs_expected) entry->eax, evmcs_expected ); break; + case 0x40000003: + TEST_ASSERT(has_irqchip || !(entry->edx & BIT(19)), + "Synthetic Timers should require in-kernel APIC"); + break; case 0x40000004: test_val =3D entry->eax & (1UL << 18); =20 TEST_ASSERT(!!test_val =3D=3D !smt_possible(), "NoNonArchitecturalCoreSharing bit" " doesn't reflect SMT setting"); + + TEST_ASSERT(has_irqchip || !(entry->eax & BIT(10)), + "Cluster IPI (i.e. SEND_IPI) should require in-kernel APIC"); break; case 0x4000000A: TEST_ASSERT(entry->eax & (1UL << 19), @@ -139,9 +147,14 @@ int main(int argc, char *argv[]) =20 TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_CPUID)); =20 - vm =3D vm_create_with_one_vcpu(&vcpu, guest_code); + /* Test the vCPU ioctl without an in-kernel local APIC. */ + vm =3D vm_create_barebones(); + vcpu =3D __vm_vcpu_add(vm, 0); + test_hv_cpuid(vcpu, false); + kvm_vm_free(vm); =20 /* Test vCPU ioctl version */ + vm =3D vm_create_with_one_vcpu(&vcpu, guest_code); test_hv_cpuid_e2big(vm, vcpu); test_hv_cpuid(vcpu, false); =20 --=20 2.47.1.688.g23fc6f90ad-goog