Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp1925987rwb; Fri, 28 Jul 2023 18:19:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlGkopxzl/edg6Js4QglQxmfBccNITbCN9uEh2vQDbLX49mDgxJBU4cB6GL5AMjQDoNYzVjp X-Received: by 2002:a17:90a:c58e:b0:262:f928:618d with SMTP id l14-20020a17090ac58e00b00262f928618dmr2448711pjt.35.1690593547424; Fri, 28 Jul 2023 18:19:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690593547; cv=none; d=google.com; s=arc-20160816; b=qaOi+KHjKzbmyj4hdGqtAqnRnQiwba4xrvr6IaXj563KKaO6bDV3YNQqhroTHGPqvk ZLCBRLsdfjWzKmYzZNqdW5LaeYPKfYRToaBwYShM9PeKTLCOa+4NPUdRxDTM2B0rspaL tCnn6IEAjIx5F7e6C9Ut0k/Cf9obZadolKTwCIqPCUnmpZiw2e4AtKZGRNvO79r+mV3g WNK2wByAEUFrvqKR+2cINRmnKjwUaYT4REyei9Cz2gUiRGKklJsMx5jlGFWOeMgfijh1 KwU18cuA2XKIpOqhMUxzTL3xC+L9bYEXuvxDWYyFfujOSJDGZrwvcfHBiFlceGgoQ9Os 0fMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:reply-to:dkim-signature; bh=AB4nCzcJxxTKK97GCB6DmZjI2HiP51XBzwyfTirQyrI=; fh=Ctt0ydInMKwei8YFBFbw7rU4p8H0G/T51ZI/KkO6Md4=; b=hf5bkwLeSuzvPHMiJIqoxDgNCHIy1SINtbrU3ixEc1QHOZnrFaovEzzOYG5o+6dXFz 3ZhdiJyT4kv4FPbUrfBg7HbQ1OxYcGWq6kDmpq/XZFBPQrWrZWFnLf3KZ7zb30u5IDt0 vIjpmpH0K8dKqfP8wejYlTPL2hhAoYWcVsorw+wilIBU9ObzLmAIsGHv3WozkyK4T+NH Fk7Hi/0Sa/0kCBMfwE84daTBkc92jharSWSPitxKy62Bh0sTFcoBMnR1JsJyAckEdGJn tbnpszf2VzVdu3wld+iNHbHWTa8pz16r4ywoGKxpqD3fal+rRcczqIhgneRTYJj4VHWK P9mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=IdcimLld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pc10-20020a17090b3b8a00b00267668f8be7si4075894pjb.64.2023.07.28.18.18.55; Fri, 28 Jul 2023 18:19:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=IdcimLld; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236909AbjG2Ak4 (ORCPT + 99 others); Fri, 28 Jul 2023 20:40:56 -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-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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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/testing/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; } -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; - 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); } 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; - if (get_ucall(vcpu, &uc) == UCALL_UNHANDLED) { - uint64_t vector = uc.args[0]; - - TEST_FAIL("Unexpected vectored event in guest (vector:0x%lx)", - vector); - } + if (get_ucall(vcpu, &uc) == UCALL_UNHANDLED) + REPORT_GUEST_ASSERT(uc); } const struct kvm_cpuid_entry2 *get_cpuid_entry(const struct kvm_cpuid2 *cpuid, -- 2.41.0.487.g6d72f3e995-goog