From mboxrd@z Thu Jan 1 00:00:00 1970 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 B6104C433F5 for ; Mon, 11 Apr 2022 09:46:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344682AbiDKJsT (ORCPT ); Mon, 11 Apr 2022 05:48:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344733AbiDKJrx (ORCPT ); Mon, 11 Apr 2022 05:47:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ADA83B2A6; Mon, 11 Apr 2022 02:45:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A99746116C; Mon, 11 Apr 2022 09:45:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F43EC385AA; Mon, 11 Apr 2022 09:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649670339; bh=/RAQFJr+K4PpHLLB41KdKOfbIHgWBUDaHpo+GIY4Jf4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Bi+OzNKz0k9mm8PsKRDLKvHTvHZA16uvfJGsWqtEoPl/wopBZUg+9T9xuNHdQ7ZmX PPJEV7hEjrDG6BgFN0rlJ98Hebzk0giXDYCotP/eXbI4egnCp1te8EHXwN0AyTiEPY 59pNkdRf58V8/086MsqYRQgevytVKqguikRIoimoMViXjQNMv7U81xliQ1sq+8B68V pBihOvxkshskhPfvCwxvWhOwvV5IG4iApV5q3kQj5gTvRToFiDForLTN6yphHNvyEu 7iu+tNokxFOE0O3F+wVuDHj1X1Kz2Iczoub/2IukCfr6UIE0Or55uunTaQ76W835Au 061CiseqLjbaw== Received: from sofa.misterjones.org ([185.219.108.64] helo=why.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ndqc4-003Hmr-F6; Mon, 11 Apr 2022 10:45:36 +0100 Date: Mon, 11 Apr 2022 10:45:35 +0100 Message-ID: <87czhoar7k.wl-maz@kernel.org> From: Marc Zyngier To: Paolo Bonzini Cc: Peter Gonda , kvm@vger.kernel.org, Sean Christopherson , linux-kernel@vger.kernel.org, Will Deacon Subject: Re: [PATCH v4.1] KVM, SEV: Add KVM_EXIT_SHUTDOWN metadata for SEV-ES In-Reply-To: <20220408165641.469961-1-pbonzini@redhat.com> References: <20220407210233.782250-1-pgonda@google.com> <20220408165641.469961-1-pbonzini@redhat.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: pbonzini@redhat.com, pgonda@google.com, kvm@vger.kernel.org, seanjc@google.com, linux-kernel@vger.kernel.org, will@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 08 Apr 2022 17:56:42 +0100, Paolo Bonzini wrote: > > Queued, thanks. But documentation was missing: > > diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst > index e7a0dfdc0178..72183ae628f7 100644 > --- a/Documentation/virt/kvm/api.rst > +++ b/Documentation/virt/kvm/api.rst > @@ -6088,8 +6088,12 @@ should put the acknowledged interrupt vector into the 'epr' field. > #define KVM_SYSTEM_EVENT_SHUTDOWN 1 > #define KVM_SYSTEM_EVENT_RESET 2 > #define KVM_SYSTEM_EVENT_CRASH 3 > + #define KVM_SYSTEM_EVENT_SEV_TERM 4 > + #define KVM_SYSTEM_EVENT_NDATA_VALID (1u << 31) > __u32 type; > + __u32 ndata; > __u64 flags; > + __u64 data[16]; > } system_event; > > If exit_reason is KVM_EXIT_SYSTEM_EVENT then the vcpu has triggered > @@ -6099,7 +6103,7 @@ HVC instruction based PSCI call from the vcpu. The 'type' field describes > the system-level event type. The 'flags' field describes architecture > specific flags for the system-level event. > > -Valid values for 'type' are: > +Valid values for bits 30:0 of 'type' are: > > - KVM_SYSTEM_EVENT_SHUTDOWN -- the guest has requested a shutdown of the > VM. Userspace is not obliged to honour this, and if it does honour > @@ -6112,12 +6116,18 @@ Valid values for 'type' are: > has requested a crash condition maintenance. Userspace can choose > to ignore the request, or to gather VM memory core dump and/or > reset/shutdown of the VM. > + - KVM_SYSTEM_EVENT_SEV_TERM -- an AMD SEV guest requested termination. > + The guest physical address of the guest's GHCB is stored in `data[0]`. > > Valid flags are: > > - KVM_SYSTEM_EVENT_RESET_FLAG_PSCI_RESET2 (arm64 only) -- the guest issued > a SYSTEM_RESET2 call according to v1.1 of the PSCI specification. > > +Extra data for this event is stored in the `data[]` array, up to index > +`ndata-1` included, if bit 31 is set in `type`. The data depends on the > +`type` field. There is no extra data if bit 31 is clear or `ndata` is zero. > + This has the potential to break userspace as it expects a strict match on the whole of 'type', and does not expect to treat it as a bitfield. Case in point, QEMU: accel/kvm/kvm-all.c::kvm_cpu_exec() case KVM_EXIT_SYSTEM_EVENT: switch (run->system_event.type) { CrosVM and kvmtool have similar constructs, and will break as soon as KVM_SYSTEM_EVENT_NDATA_VALID is or'ed into 'type'. M. -- Without deviation from the norm, progress is not possible.