From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 509C81DEFD4 for ; Mon, 20 Jan 2025 14:20:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737382852; cv=none; b=i63xauHbFhm5yZakX/q8rm7E9Fb752zhukV3iAVwtc88L15uooRSNBNgse4zere0GY8v0qZVOtmMW74aXOtZAOnPml5wBZieRegMWU71Dmds9iR7d59VN6T/r65l/SewFqMJHAZu6RR1j5IAjoTX7BIE+f/n94oe0vwSnpoyR4I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737382852; c=relaxed/simple; bh=nx6qFDSuHXU5+jLvEnHbxJo96kpctDpPjOqbTyejF8o=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=Q7pOgzLgt4GSyAR/gjegSwoNak+sPIpOn1Jg2tAVdtusEqYo4ZoFAOceZeg2vz/E3mBdflQtSeY/jKhOCTXbjngCCi86iZZVPcArfLWh+MuibD1k9RGeEKyUuYN8Y1eQhv2IdHeiijAIp1tCfk2AGVqz/mMonaE5qdKpUKWcKus= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=YdfEdx21; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="YdfEdx21" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737382850; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=I4rjvwRbHp/ejyDth9c4qQFSemdyjYcY3QB2/oRm5rI=; b=YdfEdx21we0u3mNcg2mjaLxJ3a/T1tndbjTnhr35jgTSvQvSlkgTfmaDrou22YeGnjzvBS gWjZaYnxG9eZwTVIw2DDS1akUVLahCbDfs+2OzTOFoGpi2lKMzdBL6uCZunvkW059LEYSx r9r3FAQxJCXWqbxyF1qy6QjjAZuwRf0= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-257-gjRrAGKrMm2DQbOfu5v9IA-1; Mon, 20 Jan 2025 09:20:49 -0500 X-MC-Unique: gjRrAGKrMm2DQbOfu5v9IA-1 X-Mimecast-MFC-AGG-ID: gjRrAGKrMm2DQbOfu5v9IA Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-4362b9c15d8so23607165e9.3 for ; Mon, 20 Jan 2025 06:20:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737382848; x=1737987648; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=I4rjvwRbHp/ejyDth9c4qQFSemdyjYcY3QB2/oRm5rI=; b=wcpRuB+g0+o3ZbX12gWfXl9e0f5MPXDJkDwdjAVui0ZbO9H5RJllrC6eBCwoRQ8ygI IdQQQ4hzF1OVo8fhACTmB/xb+KPAWv8USLduS1jN7JAfcUP5S202VMZIre0/P7zVAKE3 nqardqXEuyYohUxLMkV6/ys52W7tFWBKhmQ9A6wYzsLM6KY8J7py4+3KlwSzqgXvR22P GmP0/GY6jfWCebsNc6qq3zjvbQeH0uh4iYV6Qe/UCOctNFN97gWJRIiSBn4dbsjqpoaO t227Z6IGdqr/I8CI5IJudbeeG7s9MBtVrGhsKPnfWmwK9fG9XLqR7rZD3eMENW314gXe b/og== X-Forwarded-Encrypted: i=1; AJvYcCXkcurTEEWX84FIKVgc7Joun7YwNCzqDN8ZwzGG1GvxFvO/KwyEYPi5Ry9ZSk8CQUZ3vMuUFD1VEoVZj24=@vger.kernel.org X-Gm-Message-State: AOJu0Yxw/3XVYsyR4co98VSQ9qHHzObe321ql6qagdyh/bsv/z6rVq13 z5sOlsNOGdjV1VhKUaU+3kyQcwHa0w+77CAmX2iQ30RUtgt3VGXyfvyGP4zZ2ZD6dLvQKF74S3u sx5deIs4aZu0278EyxEsyyQNn4si3b9eMSuYhMpe0cQ7UP027al7ily2VaFcFyJHFsAwjsA== X-Gm-Gg: ASbGncsE6E/HG4g9O5mm49ABcBOoq4njwg6j6AAnfe8AGq1h/oYaeT5hsMABopoP/KP VtT9kzXZm5cPRrnutXKRWJte38Xfc8PQ+3VznEcTV2m/ze+DYy0v+TEWQJrUykujK9uGylpiUKP BXNBT80q5+0NtF8EKN32CExX9bsNOFie5+xCUHdoFjwKVciR+XJTa2RrBYll2M+SXCI9aioZJy3 2QtbpLsUQkujzvJEMDlqtMjSroxAq+2fRTcwmOM3mQ50KDJDc5BLBR3axH81gh7 X-Received: by 2002:a05:600c:4e4f:b0:434:f767:68ea with SMTP id 5b1f17b1804b1-438913bf92cmr145256305e9.5.1737382847792; Mon, 20 Jan 2025 06:20:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IF9/eXpkW1p7eS6BjFhNwAWx80Xw8+DRkZCUv8g1NkiVsgdzoJTpBZAB0S5w0R90ueiojf7Ig== X-Received: by 2002:a05:600c:4e4f:b0:434:f767:68ea with SMTP id 5b1f17b1804b1-438913bf92cmr145255985e9.5.1737382847412; Mon, 20 Jan 2025 06:20:47 -0800 (PST) Received: from fedora (g2.ign.cz. [91.219.240.8]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43890462195sm140441565e9.30.2025.01.20.06.20.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2025 06:20:47 -0800 (PST) From: Vitaly Kuznetsov To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Dongjie Zou Subject: Re: [PATCH v2 4/4] KVM: selftests: Add CPUID tests for Hyper-V features that need in-kernel APIC In-Reply-To: <20250118003454.2619573-5-seanjc@google.com> References: <20250118003454.2619573-1-seanjc@google.com> <20250118003454.2619573-5-seanjc@google.com> Date: Mon, 20 Jan 2025 15:20:46 +0100 Message-ID: <877c6p8t35.fsf@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Sean Christopherson writes: > 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/testing/selftests/kvm/x86_64/hyperv_cpuid.c > index 3188749ec6e1..8f26130dc30d 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) > > static void test_hv_cpuid(struct kvm_vcpu *vcpu, bool evmcs_expected) > { > + const bool has_irqchip = !vcpu || vcpu->vm->has_irqchip; > const struct kvm_cpuid2 *hv_cpuid_entries; > int i; > int nent_expected = 10; > @@ -85,12 +86,19 @@ static void test_hv_cpuid(struct kvm_vcpu *vcpu, bool evmcs_expected) > entry->eax, evmcs_expected > ); > break; > + case 0x40000003: > + TEST_ASSERT(has_irqchip || !(entry->edx & BIT(19)), > + "Synthetic Timers should require in-kernel APIC"); Nitpick: BIT(19) of CPUID.0x40000003(EDX) advertises 'direct' mode for Synthetic timers and that's what we have paired with lapic_in_kernel() check. Thus, we may want to be a bit more specific and say "Direct Synthetic timers should require in-kernel APIC" (personally, I'd prefer "Synthetic timers in 'direct' mode" name but that's not how TLFS calls them) or something similar. (feel free to address this small rant of mine upon commit or just ignore) > + break; > case 0x40000004: > test_val = entry->eax & (1UL << 18); > > TEST_ASSERT(!!test_val == !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), > @@ -145,9 +153,14 @@ int main(int argc, char *argv[]) > > TEST_REQUIRE(kvm_has_cap(KVM_CAP_HYPERV_CPUID)); > > - vm = vm_create_with_one_vcpu(&vcpu, guest_code); > + /* Test the vCPU ioctl without an in-kernel local APIC. */ > + vm = vm_create_barebones(); > + vcpu = __vm_vcpu_add(vm, 0); > + test_hv_cpuid(vcpu, false); > + kvm_vm_free(vm); > > /* Test vCPU ioctl version */ > + vm = vm_create_with_one_vcpu(&vcpu, guest_code); > test_hv_cpuid_e2big(vm, vcpu); > test_hv_cpuid(vcpu, false); Reviewed-by: Vitaly Kuznetsov -- Vitaly