Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp1106145lqo; Fri, 17 May 2024 10:47:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWM8fmnjOhoN+nzj/DpnktpTXny11zuuvv2CjXB+WmboKukLwCW07QcmDbMHcrtz8t0W0+pPiwJyVlqbRYr5RqIdhblK7kRrhjIDxRTRA== X-Google-Smtp-Source: AGHT+IGRlprgewCh0yrolsRFlz29t00A609VrEQRoGq0qXgV9bpJeXzRaUfP4ejioS/XNkFgK05f X-Received: by 2002:a17:906:394e:b0:a59:cb29:3fac with SMTP id a640c23a62f3a-a5a2d68aad7mr1598219966b.65.1715968058112; Fri, 17 May 2024 10:47:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715968058; cv=pass; d=google.com; s=arc-20160816; b=RHkHaf1OUaNDGBZBT8WvKhXgXximcz7M8cnseh4OArCFlDl2jLsY5nSN7iHMrfjbuQ V4doRNOuwWIjR9rjnXWDn4gaxar+vQiN2gDdgdBNDLvgyzKFTh7xvt80/6TUiZ8lMw+Y 4ALquXZhweenywdH4CqkMvtn0tsIpis/3zlQTXEvwtL/GB1mcfk3mBNxNdZM8Bzc6HiC FTF95qpDHhq60sABFbW1Zmf3Ta5Wy/94ZwkfUOE3qOc3IqrSwmI3Shf4OywNU1HECye1 +lgSAHY1MzNs1WDvAFavUcy5H/hxTGu80dTSX71DRy1eWMsGFpGom8ynk0+xGSQ+/mrk R8Dw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=Ls63tfw1LENdu/wncAT6gu4iTMBSH9cLRZDJ5lKbc4Y=; fh=75gVz6/Xlf2j8P9+gdWl7/bYTBDKrXUkBRkFgBPMA3s=; b=aTxwlFcuvYA9/yhx+YExD3iUedqYfOAgCjgAe6RY+GhwO8szAGxJ6ASdcOqeLEgiED eO/+6K6Osf4fA6h0Oed1eZ4cccRsnjTWDBrc9Gocg/XWkjIRz4eV5xod5uryKnw+Afc0 XMVOjvRb5dzm6wJpyC75+ZrVXEAX4T4S53ElGlbNrDel6mfuB79bfVGAJlXaI7smSW7q pmqbMQnBfW6vbqSt5JJ2Oux0914bUagxDcvojcAN7f+BTgDFSWA0MPp3c93g5QqF6e6g B77mEw60v8cjXT2vfEgEdswnzIMMfd5gMxM+P6dnJYipZLZMcOI0luwynNg4jj+er2Dm lXQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Dvtq8ZQ3; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-182438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182438-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17945eb6si1043914666b.197.2024.05.17.10.47.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 May 2024 10:47:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-182438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Dvtq8ZQ3; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-182438-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-182438-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 764321F2487A for ; Fri, 17 May 2024 17:41:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A510413DDC5; Fri, 17 May 2024 17:39:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Dvtq8ZQ3" Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.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 8064213FD87 for ; Fri, 17 May 2024 17:39:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967595; cv=none; b=Ec9/fBoL0ghLhHuSnrtwAEdjW0cgyTz91vJDx5UIUjApWylUfGZWm2PCykAsdgTAY9XWsW5NpdFRGq5n97BIh/pKKW13SMJmUWR2bETQppBDXLBSW2gNgFU+/EF1kLHwgAat49ADxdjwl13fACnA3J4UuXOaItENsMTc9lXJRJo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715967595; c=relaxed/simple; bh=aCfUY2cwJ9FyZLh6u5tXvW0EbzE1JhXczYPB0CjQxa8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=uJRH5Di5ANBuf4TgLKoOB3RXzOx3FgDkYNRYkSUNOmoXQ6zQfNvUJv8D651A8bQMW4zMJfV2S4PfcaZdLvUMtxg9XfsRJfL5HLbBqkXmgIYpbAEHhQcCv6zKXLHBiPAYZPW8qsvf1Vr9lYgHLmpu/mMUE9Yj53QIhBUO8EK/RaQ= 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=Dvtq8ZQ3; arc=none smtp.client-ip=209.85.215.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 Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-6576ea645caso2200730a12.1 for ; Fri, 17 May 2024 10:39:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715967594; x=1716572394; 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=Ls63tfw1LENdu/wncAT6gu4iTMBSH9cLRZDJ5lKbc4Y=; b=Dvtq8ZQ3kpHuzPty4e3qs4X8FTSrKc88HfCHjFTdKTVEzaQ4bjpinrsxAwDBNRYMdm qaJ14V0f1GP0eUhBbWZFd8VZnkGXCvRgbUhUkBdy49MJtJUVgc2wOhHSBXBgciEkHTKm Lo/rSVDzqQ7sFbhO2shn00BQmfAfRcL1+VLVgNAR+Tjdy0/p+sJfz5B/WC0xLXNpJMfe NA3ednm0kEPTVoiI++wWfiPbemV8yRvGZRJhqWp6seVXtWGCzqlo3TwTCMoeZfpVpRv+ n6wx+SvVHLkLDy1sYqFvVR3wOy97ZZXDm9PSmRusgJ6CKgGXzxxooW8jT6IFyMX3xGTo eLOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715967594; x=1716572394; 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=Ls63tfw1LENdu/wncAT6gu4iTMBSH9cLRZDJ5lKbc4Y=; b=r73WkvDHh/XX2AIdrwHee45jzqVr2W/RbvsW65hAFi6DVIv9lxBmjECm+pk/eBpbsm PaIOAT7ldnQDet9TJBPVn84g4ZGTo883SjDIBEgt41eXu+ecSZaHW6/c/JPP7qv6mQNQ vfMGUJHZsJlvn3RNsaFCl0hVyTP/TuDnwSw6SuV7aTd2XUIJfVGOiQ1ZgnH74XhF74L4 o+sRd/vPsAXosCdO8IocSUQqQokIByNyOCCtUzY+urWwq4dKlrTO2P8qbLAcNqM2DJJ0 m42G6k+nZywhg4QhZdirTPfgbsAOPZpYKUaGlAenWACO2nIMWU+XN+8/1b7ztC2+p7YS 6X3Q== X-Forwarded-Encrypted: i=1; AJvYcCUcUanEaiju1DR3V+Y3/mHCdFZraWJG0weVP5qPqSmaTA8ZzEeSXROCBifsuA6j3l1TR+jwSsNdILuftKdspBLnv9V/mAuLkvhh6uK+ X-Gm-Message-State: AOJu0YwXbMiVQvNjABwe2V/cTumIjF+So5oP+zvkWnoLdjRwPdkc/Hgb YifIHO7bnOS9pbHeJA3O0PclcNJCdJbV5sg+pJoPZ+1O8Z7f/1knQ242ZqSCpdX0ZcpH44YciNN HqA== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a63:b609:0:b0:619:f921:b6e0 with SMTP id 41be03b00d2f7-6373d2172afmr53642a12.5.1715967593731; Fri, 17 May 2024 10:39:53 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 17 May 2024 10:38:42 -0700 In-Reply-To: <20240517173926.965351-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: <20240517173926.965351-1-seanjc@google.com> X-Mailer: git-send-email 2.45.0.215.g3402c0e53f-goog Message-ID: <20240517173926.965351-6-seanjc@google.com> Subject: [PATCH v2 05/49] KVM: selftests: Assert that the @cpuid passed to get_cpuid_entry() is non-NULL From: Sean Christopherson To: Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Hou Wenlong , Kechen Lu , Oliver Upton , Maxim Levitsky , Binbin Wu , Yang Weijiang , Robert Hoo Content-Type: text/plain; charset="UTF-8" Add a sanity check in get_cpuid_entry() to provide a friendlier error than a segfault when a test developer tries to use a vCPU CPUID helper on a barebones vCPU. Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/lib/x86_64/processor.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c index c664e446136b..f0f3434d767e 100644 --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c @@ -1141,6 +1141,8 @@ const struct kvm_cpuid_entry2 *get_cpuid_entry(const struct kvm_cpuid2 *cpuid, { int i; + TEST_ASSERT(cpuid, "Must do vcpu_init_cpuid() first (or equivalent)"); + for (i = 0; i < cpuid->nent; i++) { if (cpuid->entries[i].function == function && cpuid->entries[i].index == index) -- 2.45.0.215.g3402c0e53f-goog