Received: by 2002:a05:6512:3d0e:0:0:0:0 with SMTP id d14csp16422lfv; Tue, 12 Apr 2022 15:23:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0WMpM6pcxwqhtCiGgdrRMkDiVeqPohCdByfpdQ7cIGKzYd0v4M3A09qCyMBblLuLOseiD X-Received: by 2002:a63:e952:0:b0:382:65eb:257 with SMTP id q18-20020a63e952000000b0038265eb0257mr32405715pgj.465.1649802198332; Tue, 12 Apr 2022 15:23:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649802198; cv=none; d=google.com; s=arc-20160816; b=UJ4WMYiyDko4K3C+fBfePbUyY4wisiWpf/ai1s0nL758590und7pbUNoe91NyrT1Qb boiOtcAic41PHQci0lbV7PZa9ODaHNqCynBuzHkmXDR75XlR1/QhsQM+dtf8s4IMiBah cuSAuP6i258nZpz8P373YWkXwLIYnL0Ft1Wtx32DIu16JsuybfuZbpsxMU9L7+EUzHN6 pU4ebmG7G3XGXo0sJoZ6JShFBeRv9InZ+WQnoCO1JuVMc/PMsXEpf/zWxcXHctiKlJY3 +N3pBZbbb9vJDk8jlMC6lmWvyrIOSaQfRXneytUe1gycfq41jfknNEl4foSIZlxy1AR7 v1pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=1DXpD40Mqhj1aLFsLc5zo1W40YO/l9yE01NlompNQhE=; b=t7Q8l0CqUCsqc1ipfe8B1+XmglWGfpXjVBN9U88/JtJW8Svz5AI8O4fWOhD46VvK4J kEz7m04rizTQA9IMvbbqLILlm70qbY12B6rOqVYCgQCRwMFsyObT2q47tx17eYPOagKK d72ZE7wz0uzcnCpdNsgo4w7JkE2lOBwNjmo/mRI+CAUn3KtxfrpxRD5tO5Dv2MKCzAAH oHfuz5bPwy/dbFIr9fh1Xl5MPfh0uzmvxysZjl+V8g3N+zwdfi3gJTLXtywyHZaKCclA 8QVBnkrCs44fg0Z9L6oN9C9SzAYLh84qBAlz+D7Ff4F5thlQhrJ6+0rAvXj9eafwjoy+ sZ2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bi+OzNKz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id t33-20020a056a0013a100b00505b50ce464si9016260pfg.311.2022.04.12.15.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 15:23:18 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Bi+OzNKz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 78A1814DA3F; Tue, 12 Apr 2022 14:03:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344674AbiDKJsP (ORCPT + 99 others); Mon, 11 Apr 2022 05:48:15 -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 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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.