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,URIBL_BLOCKED,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 73EA9C433DB for ; Thu, 18 Feb 2021 19:14:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 235DD64EB4 for ; Thu, 18 Feb 2021 19:14:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234060AbhBRTNe (ORCPT ); Thu, 18 Feb 2021 14:13:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234728AbhBRRvN (ORCPT ); Thu, 18 Feb 2021 12:51:13 -0500 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D138C061574 for ; Thu, 18 Feb 2021 09:50:33 -0800 (PST) Received: by mail-pl1-x636.google.com with SMTP id u11so1630611plg.13 for ; Thu, 18 Feb 2021 09:50:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=Ar4qumgxjcARbIFNPkL/fEc8ffnJvriNV7C8I9UZSSE=; b=o9eKOmDlEvLgF6YUJdS59NPQ8hR9UNjLOg6pdh1fOYz7oj26RjNd0/gdCyvhR16Ss/ QEcxfxRP6GOdmQy214V4gKyYY4uKZib7/caSaZpMfA6vAEL6fSnN4J+vdISK4TJG9wZD thU6v9SnWg7mQLwZgyRSZptilY/oodJWLDHejowBBpAdZAvass3h+C5x4P9eYuzOrt1j DVGR5cLo9uSbG9yZjLiReEyaxEacNfhi9lV/sBvAJenk1S7uAh3hIFzCk9AyRtxwiiZo h0vkp8pTMfBjQWGQVsaqHh8ooO21nVhiEy32WU6TRpte+qrTgd5ihTtAxqPoRc/nqJK3 CMZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=Ar4qumgxjcARbIFNPkL/fEc8ffnJvriNV7C8I9UZSSE=; b=Ma9HFhXV3dyfDAeKgFrwhWhJ3QMGOAectRnNz9yD9eOanZU8q4i1dp0Ezifq5wlwie 5HZDkdpoSgSkiyp7shMkDXV5bZDzLw4C8JZtERpQjBl2GoF+kkeo/5tjBXuxAzAA5f9l /rm5fYVRNVZSLV7MwF5MzSGUap073ZYz7Rsv3WLi3mPpgeFfnXHue12W392+H+jAnvLd aQY25NGs7nU5kPew6iQEu1Pai7Ac20wUZ2JurYtR3Itc6tul68qdvioG9iZPq1NIAehp Owb7tLnf8K7estaN7IOHHr7peSO+je5KNK2n/9/6hhNE33gqVDTQzVNOPH42unLqu3P/ qNDg== X-Gm-Message-State: AOAM530yp4kAyp9sgR5ht1qto0oTZ55WS/rwsyznydocr2mo7tU3CK91 EDWfn5xcXqE/4yJHQzuAVVHrbg== X-Google-Smtp-Source: ABdhPJxae0TGH4xiwe5Lj9mlTgbQqTEgLNrW6Vk+Pi9f/XdUSadjneFfcPUzbsnvAzsiXDlRBwG2hw== X-Received: by 2002:a17:90b:4c8c:: with SMTP id my12mr4926719pjb.29.1613670632785; Thu, 18 Feb 2021 09:50:32 -0800 (PST) Received: from google.com ([2620:15c:f:10:dc76:757f:9e9e:647c]) by smtp.gmail.com with ESMTPSA id 6sm6451766pgv.70.2021.02.18.09.50.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Feb 2021 09:50:32 -0800 (PST) Date: Thu, 18 Feb 2021 09:50:25 -0800 From: Sean Christopherson To: "Kalra, Ashish" Cc: "pbonzini@redhat.com" , "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "rkrcmar@redhat.com" , "joro@8bytes.org" , "bp@suse.de" , "Lendacky, Thomas" , "x86@kernel.org" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "srutherford@google.com" , "venu.busireddy@oracle.com" , "Singh, Brijesh" Subject: Re: [PATCH v10 10/16] KVM: x86: Introduce KVM_GET_SHARED_PAGES_LIST ioctl Message-ID: References: <7266edd714add8ec9d7f63eddfc9bbd4d789c213.1612398155.git.ashish.kalra@amd.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 On Thu, Feb 18, 2021, Kalra, Ashish wrote: > From: Sean Christopherson > > On Thu, Feb 18, 2021, Kalra, Ashish wrote: > > From: Sean Christopherson > > > > On Wed, Feb 17, 2021, Kalra, Ashish wrote: > > >> From: Sean Christopherson On Thu, Feb 04, 2021, > > >> Ashish Kalra wrote: > > >> > From: Brijesh Singh > > >> > > > >> > The ioctl is used to retrieve a guest's shared pages list. > > >> > > >> >What's the performance hit to boot time if KVM_HC_PAGE_ENC_STATUS > > >> >is passed through to userspace? That way, userspace could manage > > >> >the set of pages >in whatever data structure they want, and these get/set ioctls go away. > > >> > > >> What is the advantage of passing KVM_HC_PAGE_ENC_STATUS through to > > >> user-space ? > > >> > > >> As such it is just a simple interface to get the shared page list > > >> via the get/set ioctl's. simply an array is passed to these ioctl > > >> to get/set the shared pages list. > >> > >> > It eliminates any probability of the kernel choosing the wrong data > >> > structure, and it's two fewer ioctls to maintain and test. > >> > >> The set shared pages list ioctl cannot be avoided as it needs to be > >> issued to setup the shared pages list on the migrated VM, it cannot be > >> achieved by passing KVM_HC_PAGE_ENC_STATUS through to user-space. > > >Why's that? AIUI, KVM doesn't do anything with the list other than pass it > >back to userspace. Assuming that's the case, userspace can just hold onto > >the list >for the next migration. > > KVM does use it as part of the SEV DBG_DECTYPT API, within sev_dbg_decrypt() > to check if the guest page(s) are encrypted or not, and accordingly use it to > decide whether to decrypt the guest page(s) and return that back to > user-space or just return it as it is. Why is handling shared memory KVM's responsibility? Userspace shouldn't be asking KVM to decrypt memory it knows isn't encrypted. My understanding is that bogus decryption won't harm the kernel, it will only corrupt the guest. In other words, patch 16 can be dropped if managing the set of shared pages is punted to userspace.