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 X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4920AC433EF for ; Thu, 9 Sep 2021 18:13:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 316F46105A for ; Thu, 9 Sep 2021 18:13:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243881AbhIISOZ (ORCPT ); Thu, 9 Sep 2021 14:14:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244751AbhIISOT (ORCPT ); Thu, 9 Sep 2021 14:14:19 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBF8DC061574 for ; Thu, 9 Sep 2021 11:13:09 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id u11-20020a17090adb4b00b00181668a56d6so2060328pjx.5 for ; Thu, 09 Sep 2021 11:13:09 -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=oYzdplyM18KY0Rs8AvP7jRRMtS3fev77XkdskNX9cmc=; b=ZR+lGDI9LQg3dBtisyxTNm+HrbpIznzitrU0/yGTRHNMwChDKiR/owHUXKZTFgn/DW lDK+N+zsp3x/AcjIhqSh64wZcb/Fg4Um1uwRLHAf5ISFDW2KRa9ttt8Z1Rn4hqT9YX5c 6J6gFEa93O2XZ3gmgfvfHywZwVUHzwRmdCdHW2malFgfBuBU3FAhksfJZESzKGjpX11g pJmYmOetRt5HuKgC+7I49jLfrUHg5jhqnRw0kiCmjldscemLhWTopFYo1Lbb3M9L7UUC zwa+C/MspbQlDyNCK78koAsA4WHdGMom9cWg+O0zfZKB6oiwtXKK8rSJ/b73ojpVzwah oTvg== 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=oYzdplyM18KY0Rs8AvP7jRRMtS3fev77XkdskNX9cmc=; b=M1vMRN3fS5RLtjgcux49cSP7C0nCueKiyPT+jcJi0nLvnhqlJ9fNLugzxZf43F8mkd VtjdUXB8mipiXMmS/nrlEwoz/ceCTcEV2EDAHqUsjIGbrl26uR8QKP7IzuO8TMLEwF1S C6DnCFwXp8ZUXdvpTS8hndXWIi8j4HSgwFL30IXMfCltNIOuBd3q17I30BbNNQrYHYm0 /HlNNXIINfuuJX8bwvYmn3hefXwiMnh/QXjdp5sMwDZDeyHFqlOlVQzW3rbBqGyrX8m/ sibntbYcDILQ+MASs+DXhjd1i4awmWFaqEZBJFqmwz2udxj1DFTGuTQAn5hVdM5TexsL uZzQ== X-Gm-Message-State: AOAM531sm9FpPE+YfyHGcEuZn4wroNJQaNEvkXxwsvLJO0E/FExKmYcH R349EbXv8pYboJvfMvoULXlrTQ== X-Google-Smtp-Source: ABdhPJwjxNZvs52Wb3cW5/9xyK/4w0Xli94hIemVpgz29jXOSyfDxRN91mAeYXb0+lxKj6DstTdWHg== X-Received: by 2002:a17:902:7c93:b0:13a:a1e:dd2d with SMTP id y19-20020a1709027c9300b0013a0a1edd2dmr3821810pll.12.1631211189217; Thu, 09 Sep 2021 11:13:09 -0700 (PDT) Received: from google.com (157.214.185.35.bc.googleusercontent.com. [35.185.214.157]) by smtp.gmail.com with ESMTPSA id h20sm2876865pfn.173.2021.09.09.11.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 11:13:08 -0700 (PDT) Date: Thu, 9 Sep 2021 18:13:05 +0000 From: Sean Christopherson To: Brijesh Singh Cc: Mingwei Zhang , Paolo Bonzini , Tom Lendacky , John Allen , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Alper Gun , Borislav Petkov , David Rienjes , Marc Orr , Peter Gonda , Vipin Sharma Subject: Re: [PATCH v2 3/4] KVM: SVM: move sev_bind_asid to psp Message-ID: References: <20210818053908.1907051-1-mizhang@google.com> <20210818053908.1907051-4-mizhang@google.com> <8421f104-34e8-cc68-1066-be95254af625@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8421f104-34e8-cc68-1066-be95254af625@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 09, 2021, Brijesh Singh wrote: > > On 9/7/21 6:37 PM, Sean Christopherson wrote: > > On Tue, Sep 07, 2021, Brijesh Singh wrote: > > > I have no strong preference for either of the abstraction approaches. The > > > sheer number of argument can also make some folks wonder whether such > > > abstraction makes it easy to read. e.g send-start may need up to 11. > > > > Yeah, that's brutal, but IMO having a few ugly functions is an acceptable cost if > > it means the rest of the API is cleaner. E.g. KVM is not the right place to > > implement sev_deactivate_lock, as any coincident DEACTIVATE will be problematic. > > The current code "works" because KVM is the only in-tree user, but even that's a > > bit of a grey area because sev_guest_deactivate() is exported. > > > > If large param lists are problematic, one idea would be to reuse the sev_data_* > > structs for the API. I still don't like the idea of exposing those structs > > outside of the PSP driver, and the potential user vs. kernel pointer confusion > > is more than a bit ugly. On the other hand it's not exactly secret info, > > e.g. KVM's UAPI structs are already excrutiatingly close to sev_data_* structs. > > > > For future ioctls(), KVM could even define UAPI structs that are bit-for-bit > > compatible with the hardware structs. That would allow KVM to copy userspace's > > data directly into a "struct sev_data_*" and simply require the handle and any > > other KVM-defined params to be zero. KVM could then hand the whole struct over > > to the PSP driver for processing. > > Most of the address field in the "struct sev_data_*" are physical > addressess. The userspace will not be able to populate those fields. Yeah, that's my biggest hesitation to using struct sev_data_* in the API, it's both confusing and gross. But it's also why I think these helpers belong in the PSP driver, KVM should not need to know the "on-the-wire" format for communicating with the PSP. > PSP or KVM may still need to assist filling the final hardware structure. > Some of fields in hardware structure must be zero, so we need to add checks > for it. > I can try posting RFC post SNP series and we can see how it all looks. I'm a bit torn. I completely understand the desire to get SNP support merged, but at the same time KVM has accrued a fair bit of technical debt for SEV and SEV-ES, and the lack of tests is also a concern. I don't exactly love the idea of kicking those cans further down the road. Paolo, any thoughts?