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 D760EC433EF for ; Fri, 8 Apr 2022 17:01:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237985AbiDHRDe (ORCPT ); Fri, 8 Apr 2022 13:03:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231248AbiDHRDa (ORCPT ); Fri, 8 Apr 2022 13:03:30 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 779261A6E59 for ; Fri, 8 Apr 2022 10:01:26 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id y8so3709148pfw.0 for ; Fri, 08 Apr 2022 10:01:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=eWqSaaArcKpWGewd/PpIagLrNxnVfrX7eeJw2V+0bsU=; b=e/45W54vRn2wXoqJKapVjNEBlsEKPzVALK2ZnAsyFTU2/VLcvfFN2z/PxuDrnf5yYr wzIZFXscKl8tHOtv/5026QUqf5dZEVpW5xXL+BJhaMbKHsMcXaLbg3UDu/MPSYtSCJpD NStDS1RhCtWJEloYe2nnA9d03udZ98pC6ACDsUDlQiTQARKIv5X7uaNW5SFBVwO/MRUA le3GLs6AS9o+aCulMgFQ/uPSlx88/hkf0J7s+PGqEP08qCYcHxEd+xmJzW+0539J/wiV XZmLF7RhSiYxp0yJxVQXu2Fh70FpHZTcMsLNb16H5o5qr/tR61TwEg60MtEePoW/jwCf t7qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=eWqSaaArcKpWGewd/PpIagLrNxnVfrX7eeJw2V+0bsU=; b=ZdSFCug4q9Msap9O8iiJWyyTBcx+eY0bUUEZgyeiQin8OGic3vE9rP3cAfvIrt+A2L rd13cHs2K5Vctk1gFEXS3s2S7oaQv/i4Ew4xrLTLKrZPRoYtaEy4PAtU4Pu4TVk9uanI ISRhYf4+fUXJn4ZX3+IWugmfexkDaB6OwRcUKB0n9UH2Uq0K/y42VGQrEGe2z8IxUbM2 B1y5/5auOY1U37BlnkwirmDd5OCFebqV3p77Tlz7rpqD/F27Z8Af6VDwxRvhiTE+IRB2 rbm1WDWxwVZfYV11Xy124u+/vkILyL72vTzOCNU6QQdfaW2AjdkjejdBDmoaRZKJQJJO JOGA== X-Gm-Message-State: AOAM533vigMijZXVCdF/wJU95qMXmkep7skbMhWjEjuzcLcq6SQqMnAB 9aPvTtm+KlpnV8Sf3JjBZ3mWdiIVambcNw== X-Google-Smtp-Source: ABdhPJx61Cp20UincZxmgyHkjllgAkxu7q8n+OznXbv79pEtVaCAbT28ENVjE8GnNMEUjlgOP6uBfg== X-Received: by 2002:a05:6a00:1312:b0:4e1:58c4:ddfd with SMTP id j18-20020a056a00131200b004e158c4ddfdmr20443717pfu.65.1649437285741; Fri, 08 Apr 2022 10:01:25 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id e19-20020a637453000000b003821bdb8103sm22268448pgn.83.2022.04.08.10.01.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 10:01:25 -0700 (PDT) Date: Fri, 8 Apr 2022 17:01:21 +0000 From: Sean Christopherson To: Peter Gonda Cc: kvm list , Paolo Bonzini , LKML , Anup Patel , Will Deacon Subject: Re: [PATCH v4.1] KVM, SEV: Add KVM_EXIT_SHUTDOWN metadata for SEV-ES Message-ID: References: <20220407210233.782250-1-pgonda@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +Anup and Will On Fri, Apr 08, 2022, Peter Gonda wrote: > On Thu, Apr 7, 2022 at 8:55 PM Sean Christopherson wrote: > > > > On Thu, Apr 07, 2022, Peter Gonda wrote: > > > If an SEV-ES guest requests termination, exit to userspace with > > > KVM_EXIT_SYSTEM_EVENT and a dedicated SEV_TERM type instead of -EINVAL > > > so that userspace can take appropriate action. > > > > > > See AMD's GHCB spec section '4.1.13 Termination Request' for more details. > > > > Maybe it'll be obvious by the lack of compilation errors, but the changelog should > > call out the flags => ndata+data shenanigans, otherwise this looks like ABI breakage. > > Hmm I am not sure we can do this change anymore given that we have two > call sites using 'flags' > > arch/arm64/kvm/psci.c:184 > arch/riscv/kvm/vcpu_sbi.c:97 > > I am not at all familiar with ARM and RISC-V but some quick reading > tells me these archs also require 64-bit alignment on their 64-bit > accesses. If thats correct, should I fix this call sites up by > proceeding with this ndata + data[] change and move whatever they are > assigning to flags into data[0] like I am doing here? It looks like > both of these changes are not in a kernel release so IIUC we can still > fix the ABI here? Yeah, both came in for v5.18. Given that there will be multiple paths that need to set data, it's worth adding a common helper to the dirty work. Anup and Will, system_event.flags is broken (at least on x86) due to the prior 'type' field not being propery padded, e.g. userspace will read/write garbage if the userspace and kernel compilers pad structs differently. struct { __u32 type; __u64 flags; } system_event; Our plan to unhose this is to change the struct as follows and use bit 31 in the 'type' to indicate that ndata+data are valid. struct { __u32 type; __u32 ndata; __u64 data[16]; } system_event; Any objection to updating your architectures to use a helper to set the bit and populate ndata+data accordingly? It'll require a userspace update, but v5.18 hasn't officially released yet so it's not kinda sort not ABI breakage.