From nobody Tue Dec 16 03:18:30 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3F97C001DE for ; Sat, 29 Jul 2023 00:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236927AbjG2Ak6 (ORCPT ); Fri, 28 Jul 2023 20:40:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236549AbjG2AkS (ORCPT ); Fri, 28 Jul 2023 20:40:18 -0400 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5427A44AE for ; Fri, 28 Jul 2023 17:38:40 -0700 (PDT) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1bbb97d27d6so18296245ad.1 for ; Fri, 28 Jul 2023 17:38:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1690591069; x=1691195869; 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=AB4nCzcJxxTKK97GCB6DmZjI2HiP51XBzwyfTirQyrI=; b=IdcimLldL6SdT439oCWu8rz2dmrkYjv8ox3SUKWomnMiyiiFRRjDs66qRRW+FVKqrx 0i8l7UCEvYEgFtND3T2gbsKATBAqjj6umb2vG/JNBL0Mq5nZet9Wids8j4AWdk/JSW9/ JKTRfK4mCIXSn2n+AVw/lB8MDG+6y8r1BWFbxAHaWz3sWgeN3tc3CLBlVVmcA590V/pB y4wgwQpigybr8lpsL1JOF+Q3E+fGX3fNVqw4rlA7l6EtvrlD5hrwC3UZnR0P48gEV9XH gNkCLnErK0Q0pLqgIRTVaGjlOFf6bZIf8BVat9k7OjIOviPSk4Q4BvHQlNGefnt2lLFt laWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690591069; x=1691195869; 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=AB4nCzcJxxTKK97GCB6DmZjI2HiP51XBzwyfTirQyrI=; b=MCjvpU569vU2c/u+JRQ7tLToeaJ5aP+efxN6FGW2QCfynnR6fQWsPQU9n5jCZ/eXg2 RfBjaKOdCqmpakocOThlmg+3yGs0/tOHND5jgWkDim8zM+sKIMzHi3zLfmFm5yBK8Lox +4hFLFPGX7QT2v9xxfillxkiMD16+HLvuxHbA2Xj18275Sa7AWHkgb4GhshMOfu5ORfU 6MGS+mxF695oqo0/4FuNgC6J/ZJTCsMPaczXgSNZi/CuCteRCLm+G+45gSvYfHAghTNR SFs39/Tn6OLNCJbVakYc28c146AfjMN+lAPSyse91fCbOLm7wLuTb/9kg73Z7JCXNcXR elYQ== X-Gm-Message-State: ABy/qLa369PsFrPogizsG4YZnHPrSi9RANFejGHN/6CzWIm/m+95jOpG hLyGQPJyCbXpZNqOSVb11GtbgA7z07w= X-Google-Smtp-Source: APBJJlFqj3KGHz4ib/ws4V7ET96W9C6pQj8d9T5XgR4iicuixEf78OTjjLiyoxpq5Vayxs/ASyydtJHhDL0= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:ec92:b0:1b8:929f:199b with SMTP id x18-20020a170902ec9200b001b8929f199bmr12494plg.11.1690591069741; Fri, 28 Jul 2023 17:37:49 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 28 Jul 2023 17:36:42 -0700 In-Reply-To: <20230729003643.1053367-1-seanjc@google.com> Mime-Version: 1.0 References: <20230729003643.1053367-1-seanjc@google.com> X-Mailer: git-send-email 2.41.0.487.g6d72f3e995-goog Message-ID: <20230729003643.1053367-34-seanjc@google.com> Subject: [PATCH v4 33/34] KVM: selftests: Print out guest RIP on unhandled exception From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Christian Borntraeger , Janosch Frank , Claudio Imbrenda Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, Sean Christopherson , Thomas Huth , "=?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?=" , Aaron Lewis Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use the newfanged printf-based guest assert framework to spit out the guest RIP when an unhandled exception is detected, which makes debugging such failures *much* easier. Signed-off-by: Sean Christopherson --- .../selftests/kvm/lib/x86_64/processor.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/tes= ting/selftests/kvm/lib/x86_64/processor.c index d4a0b504b1e0..d8288374078e 100644 --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c @@ -1074,11 +1074,6 @@ static bool kvm_fixup_exception(struct ex_regs *regs) return true; } =20 -void kvm_exit_unexpected_vector(uint32_t value) -{ - ucall(UCALL_UNHANDLED, 1, value); -} - void route_exception(struct ex_regs *regs) { typedef void(*handler)(struct ex_regs *); @@ -1092,7 +1087,10 @@ void route_exception(struct ex_regs *regs) if (kvm_fixup_exception(regs)) return; =20 - kvm_exit_unexpected_vector(regs->vector); + ucall_assert(UCALL_UNHANDLED, + "Unhandled exception in guest", __FILE__, __LINE__, + "Unhandled exception '0x%lx' at guest RIP '0x%lx'", + regs->vector, regs->rip); } =20 void vm_init_descriptor_tables(struct kvm_vm *vm) @@ -1135,12 +1133,8 @@ void assert_on_unhandled_exception(struct kvm_vcpu *= vcpu) { struct ucall uc; =20 - if (get_ucall(vcpu, &uc) =3D=3D UCALL_UNHANDLED) { - uint64_t vector =3D uc.args[0]; - - TEST_FAIL("Unexpected vectored event in guest (vector:0x%lx)", - vector); - } + if (get_ucall(vcpu, &uc) =3D=3D UCALL_UNHANDLED) + REPORT_GUEST_ASSERT(uc); } =20 const struct kvm_cpuid_entry2 *get_cpuid_entry(const struct kvm_cpuid2 *cp= uid, --=20 2.41.0.487.g6d72f3e995-goog