From patchwork Sat Jul 29 00:36:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 13332827 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 A4EB7C001E0 for ; Sat, 29 Jul 2023 00:39:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Reply-To:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID :References:Mime-Version:In-Reply-To:Date:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DUW429eWlzdFuE0nX61JRAgcXcF4ImUzgXH1avIa6Uw=; b=utq6B5Cd9j3qez iEsCbrn2cKrDfKRMPVIgWJYm1K2TUILBjLPWQZMAbjniZ9a6N3vGIUg5MoORklCtxwvA0x7L4BrUQ BBQ9hyi09wRaGt92J4IGhkY76Unf/FgAo1LhijY7BHotsAkDFLHpLrl4NKpTI+jSz0FCtxrwjeaNW KlHdhwVLO0cA8QsvgtkADQAzUlDGylwFCn8r6ZieLcflRL9mZ0Mr2RRseRFC+CaOF74wJjD7jqhqY qPtIBq0ZOU44FuC5rxMJNxqAeNwxrw1B2Nyo51AjIphah9W0yCjzvjO8d7F9VnNsGlDFf/Gw5BdaI 1GQSlwD4tvlycH8nLOWQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qPXyb-005dZV-04; Sat, 29 Jul 2023 00:38:33 +0000 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qPXxu-005d8x-28 for linux-arm-kernel@lists.infradead.org; Sat, 29 Jul 2023 00:37:51 +0000 Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1bbb97d27d6so18296265ad.1 for ; Fri, 28 Jul 2023 17:37:50 -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=J35prqPslk/42i9DLickTxgKQvo63UQErKV2W+aw5OlHsjAEewkzp5OrWdmomWerXZ TQdnGhlFZgDVqi3XvQgGNTNgAC/fEMo2Ri/vvpYOuJFv6HNMj5YWkETc2LERGEcSfRNE zaioujH6AGCMkDKcxtgEqABAQI/5XG7lpChBUFxgnWQfxU/P78U4/0/JD9hn25+oqqKB VTQnlx/TdzqekJWC0KXMBvNQuVP67aY+Nc9DAbfmDpGpTnrrmhqxHbMWA0/G0YDrKYEh wOduAg6aYeuLsln6Rk4exPmWd519wkTwr4tYJso6HMXz1bjsLX1KR3T6Do2RzD8aXkxA 4p6A== X-Gm-Message-State: ABy/qLYh4JaVEJyrB5Z5vnSZshAjh5BPB8VB/r5oCK1elfAXEHmekxeZ PUqkqS2G+YFhiF3WSvErPjl1R07pvxw= 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) 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_Mathieu-Daud=C3=A9?= " , Aaron Lewis X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230728_173750_717945_BE66A935 X-CRM114-Status: UNSURE ( 9.89 ) X-CRM114-Notice: Please train this message. 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 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,