From patchwork Wed Sep 11 20:41:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13801091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8DC1EEE57D7 for ; Wed, 11 Sep 2024 20:49:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Reply-To:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To: From:Subject:Message-ID:References:Mime-Version:In-Reply-To:Date: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZQRYVtp40gN2JN3r5ECO8yPdv4xFpWyP5ZtXJGFNMpg=; b=QpuB7nbu2k2PVPIlNvLXPjPHss YN7xFfgeX8rVRCWpBYNIkoUFudk/0rpJDeI+1G3mNiwyQMUKtMPD9aB3udUwKtAgRs70xjf5UUp9p 2Jv+eoYzMODrVG/zzGhnGL0r3PQrFrUPTx23FEJghd1O25HWlJ5VjNJnsHkpT01tBw9ZA2AYoEz17 VXINV9u8q8+2OjPmYUrUcStfZxqwjclv/aLEhQlWwIgmTPXGDw/Hh5TBkHaIUdFYIpbToVWpqhffe Oho2WJk/Q7lcB5eg+eonebYjK2/pd+Lhq3atBWKmtJEkuWAqsQYJ87Y1pMXwXbd9LUJ8sLO8fPAPL DnPuZhgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1soUH5-0000000Az89-3Nwi; Wed, 11 Sep 2024 20:49:15 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1soUAa-0000000Awyl-1wZC for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2024 20:42:33 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6db7a8c6831so14492997b3.3 for ; Wed, 11 Sep 2024 13:42:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1726087351; x=1726692151; darn=lists.infradead.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=ZQRYVtp40gN2JN3r5ECO8yPdv4xFpWyP5ZtXJGFNMpg=; b=AQ+GzP7rN/3Izlc4lHJVwHhAu3B8+O2fPEVnH8UkWEHyiIxHqGXwY4EuloAc+13kQA tyNG8Rd7LAYiG9/bIcC7aXkUhBl9lbk/LXFVL2hZh0VMTAPkLaLfhf5qhHbK2TngpgQ+ BRYcFvNxMsDm3qpPobRwrLj5bGSdzq1ugGoOGXoeJARFBt5l5lWQw+uW8n/2AQWJkXUq 7N3m8pyxkpuwWIXBcYUAYCvILr9SBgVRN263QNRrI7LY+Z8S56VwcnhFP77xrOsjFHCr jGACSWTL9+fYe4EwE4QVgIXasF+dQKS7eJhiIKJ8HOSw1ZR8euVlTPqOpCkf62UZ2BRO AhKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726087351; x=1726692151; 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=ZQRYVtp40gN2JN3r5ECO8yPdv4xFpWyP5ZtXJGFNMpg=; b=KGL0QLvPrPJOS24CMicymBSAmEutBJf1+hmch4olAaQ4sIgajY0amrUXnQG3kKNg+i e6pHrhxqBvVhQFzCnxyJLayUTXAYaGyV6PE3kAEaiKkGHKpNgPoD2Fx2QSXLsDZRncz8 PJhx84bu8asMyZxg/tdx0SAEWjQZONFnm6p9yCXPMFWSZQvbBFFJrjVtxdvkAQJT2IHx m7/K5baCwWdtjDW+19XGXTLvRqEfWM/1V+I20E8EZMuAmCGMwZs1002MmmTZE79cgRk6 QREaksdgBfiGsEPFqm0jmHIecb5z+tnZIemws4e3khnhgy35pN44Jz9q2edUeGPqwXEP 189A== X-Gm-Message-State: AOJu0YxsftD+AC67Nw2LOeN/cp2IoceudDHnedWNEA9Xt5txW0kz89mk h5LolWhVCeVqGnOYQOiSsXtr4XtVbekLEEq6B0n3JnN6bicSq/rk1DOiLKaa2UNDwEQo/ZLH4IL Cyg== X-Google-Smtp-Source: AGHT+IH8ZQwfCbzagdZgU+EpISSX/A630EuGAq7pLp9hJDXsMNgEZzJ88I5801BwyQ8RRGJvBOpit5rNgP4= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:c711:0:b0:e0b:af9b:fb79 with SMTP id 3f1490d57ef6-e1d9dbc1dc5mr2910276.3.1726087350958; Wed, 11 Sep 2024 13:42:30 -0700 (PDT) Date: Wed, 11 Sep 2024 13:41:50 -0700 In-Reply-To: <20240911204158.2034295-1-seanjc@google.com> Mime-Version: 1.0 References: <20240911204158.2034295-1-seanjc@google.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog Message-ID: <20240911204158.2034295-6-seanjc@google.com> Subject: [PATCH v2 05/13] KVM: selftests: Check for a potential unhandled exception iff KVM_RUN succeeded From: Sean Christopherson To: Marc Zyngier , Oliver Upton , Anup Patel , Paolo Bonzini , Christian Borntraeger , Janosch Frank , Claudio Imbrenda Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Sean Christopherson , James Houghton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240911_134232_524595_DE2DAEE4 X-CRM114-Status: GOOD ( 11.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Sean Christopherson Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Don't check for an unhandled exception if KVM_RUN failed, e.g. if it returned errno=EFAULT, as reporting unhandled exceptions is done via a ucall, i.e. requires KVM_RUN to exit cleanly. Theoretically, checking for a ucall on a failed KVM_RUN could get a false positive, e.g. if there were stale data in vcpu->run from a previous exit. Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/lib/kvm_util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 56b170b725b3..0e25011d9b51 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -1719,7 +1719,8 @@ int _vcpu_run(struct kvm_vcpu *vcpu) rc = __vcpu_run(vcpu); } while (rc == -1 && errno == EINTR); - assert_on_unhandled_exception(vcpu); + if (!rc) + assert_on_unhandled_exception(vcpu); return rc; }