From patchwork Fri Mar 11 17:57:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 12778492 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 78F3DC433EF for ; Fri, 11 Mar 2022 17:59:09 +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:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Hz2cnKnjC0LJewY41vbHRNVdYkMBVk/5SWbg0rmZvZI=; b=oOs+gv7f1sVckEmqhn9Qea+Cox d260wvscg64/xJ2Dchdse4dPEtuhk/eXcaki4qP6Dxz0hsVP8GA/Jd2rx7JhtDwZSUdX9dUTI9iut HC1EWKHuU2pw6nO6heqneOB0u72KCuC+Q6Qa4Y/zxvz9CrcwLAqfNlF/yAPui/l7ldvZav2Dc7YC3 +ReNLacjwCVSTVSkfe0m7f3PQoyH1zhJ22FlGbZUsSDpF0oziDOMAzdXkCf5LCtns/WgM4b2pjDv+ q/TpB8J0D3MLD5ztR5ove6ot1tePYyEDh8nygYQbQDMUA2RuUsgnQ1by42J3aNtyPVssKVF8FktIn /JIfZXGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nSjWW-00HYOJ-B2; Fri, 11 Mar 2022 17:57:56 +0000 Received: from mail-io1-xd4a.google.com ([2607:f8b0:4864:20::d4a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nSjWI-00HYGv-PJ for linux-arm-kernel@lists.infradead.org; Fri, 11 Mar 2022 17:57:44 +0000 Received: by mail-io1-xd4a.google.com with SMTP id d19-20020a0566022bf300b00645eba5c992so6810072ioy.4 for ; Fri, 11 Mar 2022 09:57:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=reY3JxO0Qz3iJXrFE+fLTwQO2MuKL1UPGAjn20Lqoao=; b=n/M+lnBk+N7zApRlOssTP+KALpqfkDUpxmbbZf9OVnsbAGTF24lyWr2yvrKj3eJhHh KlwuG3VKWe3524zQ0pEL4J6TBwFwPOoRAebN3n0vpides8mGXB+EbYFeJmmkZfQTfGzZ XYvyGdDyjkXVzSAzkiq91lVWeQmg14E+ZshflwW/ntyiQxAJxwuPNucacslawQCbPYYm WD3ZFVMIGBG78tv4VKrrv5Q/SbGCWnBDtlQP2/T9o/33WqeTY/4Pf+YD0SNDX81gEwaX G3KYqOFofFz3jHwq3lO7/3gzvWvfYvIGk9aFdVJLuYnlmsuLWzAaO0YJUmB9pJCY0LLG 0zmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=reY3JxO0Qz3iJXrFE+fLTwQO2MuKL1UPGAjn20Lqoao=; b=lmCerL5qdfjl3A4t97vzBRIekY7N9DSwpPY8ucrRwi0e44/aTe7e1Gx3SKL+zOVjAt thxg9YpIFEewmCe53dPxtpzujMons9OIpUffAQpjlf1/tt159gXPA9n3nRGsqOagQeHm upSkKQxp+2CVFMJyeYapWFyuxJ5B6txBj03hGJGlA5N4UTJV5pRPzvppQKXPKFCBHfIN gIhXpgiiyJ+165dPbcji/nn0FWsvaUBuES7RQSnuihvrnZdUk0kYI/Dgrm8fQ+EpXsUt i+U7uBDgjmrUSRmBLH2sBf1EvEkLeUjEoZXoBnOoMnxY9gbKgeAOZks0I9mijmSREllc 6vyA== X-Gm-Message-State: AOAM530Mmt5J+T2yAL6deiqV7XkXh3Y9raFcV0SUlD1j2pJO13mYo7/V 2It5tBRjglo0JgZfYurfk0O1K2NEsLQ= X-Google-Smtp-Source: ABdhPJwIV2dE5aKw/FZ4JxGUOLBoR07htZIM8UZWxJDfUBN8z5M+T3xIKkUCNUzF/rey8m9ZGZWSrRl15SE= X-Received: from oupton.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:404]) (user=oupton job=sendgmr) by 2002:a02:a081:0:b0:317:b141:29ca with SMTP id g1-20020a02a081000000b00317b14129camr9018933jah.275.1647021461237; Fri, 11 Mar 2022 09:57:41 -0800 (PST) Date: Fri, 11 Mar 2022 17:57:14 +0000 In-Reply-To: <20220311175717.616958-1-oupton@google.com> Message-Id: <20220311175717.616958-3-oupton@google.com> Mime-Version: 1.0 References: <20220311174001.605719-1-oupton@google.com> <20220311175717.616958-1-oupton@google.com> X-Mailer: git-send-email 2.35.1.723.g4982287a31-goog Subject: [RFC PATCH kvmtool 2/5] Allow architectures to hook KVM_EXIT_SYSTEM_EVENT From: Oliver Upton To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , linux-arm-kernel@lists.infradead.org, Peter Shier , Ricardo Koller , Reiji Watanabe , Will Deacon , Julien Thierry , Oliver Upton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220311_095742_868919_C04242B5 X-CRM114-Status: GOOD ( 10.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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Certain system events require architecture-specific handling. Allow architectures to intervene for exits unhandled by the default exit handler. Signed-off-by: Oliver Upton --- include/kvm/kvm-cpu.h | 1 + kvm-cpu.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/kvm/kvm-cpu.h b/include/kvm/kvm-cpu.h index 0f16f8d..75e42d8 100644 --- a/include/kvm/kvm-cpu.h +++ b/include/kvm/kvm-cpu.h @@ -20,6 +20,7 @@ void kvm_cpu__run(struct kvm_cpu *vcpu); int kvm_cpu__start(struct kvm_cpu *cpu); bool kvm_cpu__handle_exit(struct kvm_cpu *vcpu); int kvm_cpu__get_endianness(struct kvm_cpu *vcpu); +bool kvm_cpu__arch_handle_system_event(struct kvm_cpu *vcpu); int kvm_cpu__get_debug_fd(void); void kvm_cpu__set_debug_fd(int fd); diff --git a/kvm-cpu.c b/kvm-cpu.c index 7dec088..d615c37 100644 --- a/kvm-cpu.c +++ b/kvm-cpu.c @@ -23,6 +23,11 @@ int __attribute__((weak)) kvm_cpu__get_endianness(struct kvm_cpu *vcpu) return VIRTIO_ENDIAN_HOST; } +bool __attribute__((weak)) kvm_cpu__arch_handle_system_event(struct kvm_cpu *vcpu) +{ + return false; +} + void kvm_cpu__enable_singlestep(struct kvm_cpu *vcpu) { struct kvm_guest_debug debug = { @@ -224,6 +229,9 @@ int kvm_cpu__start(struct kvm_cpu *cpu) */ switch (cpu->kvm_run->system_event.type) { default: + if (kvm_cpu__arch_handle_system_event(cpu)) + break; + pr_warning("unknown system event type %d", cpu->kvm_run->system_event.type); /* fall through for now */