Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp719119pxu; Thu, 7 Jan 2021 16:59:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJzAxV3SVbOPxJsfuBSqE+0o4bfayhID5IFbE/t5SLCcyjGO0aDw/SPHPS8QeNokYBoudEh0 X-Received: by 2002:aa7:df0f:: with SMTP id c15mr3583439edy.354.1610067541288; Thu, 07 Jan 2021 16:59:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610067541; cv=none; d=google.com; s=arc-20160816; b=mVvey+geTVE5/CLql8tbdOTGd18Bf3e8hYiHpba+muoGZCYvYroJFzLyj0VV2N8+ff UORgQt5J4vs+95DX7ovamVbuz/4m9iyTZcDUUz8vCogJU/B+3AgIJ3mUt7Bimu5h/db1 agPaZJEtf8rTkNnJSv+SDJje5DOLX/SWN+Noo5hGa1PmaLOapAEP9KG95JIqU58zDUV7 pE18WEiQDlxJwgSpomUjEZZnmDf4+p6M6CeRvOdOmxnHRk7TOw2uUNpcekaKrByDdyRa +ooHB0YCcv/RejXpWZ5X1LsPTt70MFGgqUNdFrSujBZIZXbVQWNmsQb6V31JQsHPUK0D byGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=YFEuVUC8aA7NY7eBZYfyGxeTh/eqcKZZ4JvsuQQiSyE=; b=p+LHXMVTTbEGziDnujDsCLF3VaTpyxpmc7LvHm5eHlD9qbinjz2PBBZGtzfR8H9H7s eGD5SzY6D6dBrOv3GuJcEC+OtDarvNwJQyWswTF11sXJafI6e+agsOtnsaN1QXhJA5pG jWjBqECB4bKagQH+piJYjOgH/Z2SZkgsTF7Wo/4ECHgaUE961nUtZfmHHswmkRty7PWU nZZHYivLwZblTAjnv9nTUoB5O/P1yRzBJzmYFmupXQNwbx+t1otEhynYuHDuF+zBpF2M K+WzoVkXQ3efLDyERMPu2imXo689cULeu94+DA29eAgBRhy7Dp2CRW3j1pIRDJQkoeCr GZPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="p/OG6jEu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k10si2916967eji.9.2021.01.07.16.58.37; Thu, 07 Jan 2021 16:59:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="p/OG6jEu"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729741AbhAHA4d (ORCPT + 99 others); Thu, 7 Jan 2021 19:56:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729599AbhAHA4c (ORCPT ); Thu, 7 Jan 2021 19:56:32 -0500 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91038C0612F8 for ; Thu, 7 Jan 2021 16:55:51 -0800 (PST) Received: by mail-il1-x136.google.com with SMTP id q5so8628022ilc.10 for ; Thu, 07 Jan 2021 16:55:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YFEuVUC8aA7NY7eBZYfyGxeTh/eqcKZZ4JvsuQQiSyE=; b=p/OG6jEu5ut6T7CABzrHvQr8IvhK9OHCHolTHtDS+7trzI0kxcQ9wVzHHeaFLEHxMc sHWcen7E+eTdA/lhCjNXKQ6UbiaXlQhukFOEI1EV32xBGhm38jAhqjzA9HOIffCWSxsI WW8hJ21NYlcP0OTlFcAyvgZInKY03hfrT5coh/Taoe4upoZ8th+1xgcDWJhDxqEVY4P0 2l4ya0VuiHYUBTUEtCaklKBbptGVifAQ9n6NZi47VUKP2e3+IQIQpl5f+UoHaSh2hfi+ GWCSQakGjOASBDdXB0F3ZFBAK7PcPz++56IkdzsbM1XBb174EeFDTdd1ayBeQewVnF4L TL7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YFEuVUC8aA7NY7eBZYfyGxeTh/eqcKZZ4JvsuQQiSyE=; b=dlOdNVXLMoV4PSnx/Qf5hSDDD++VdwOZ+qEpLETJuFgbUcl5JR5qoyTrmVrCK2elgO bcpONmW3xh67zx55RcQNLYOOnxKrGVEA3EbbY/xe1DbdPq5/KALYzv3La0z0xJRCBU4i 7ZGEUuHOGZmJ3EiHiATjFqL0OBjuOhmP08yzM+p/cf0IgWR+QOzy746czy6KB/Fow370 /XWONiOTPQu4CrcrPqmjDzizM/aPrIHsjrZ9vnIu+/mcqO4gN/c1xEO/c2szntGc/mP5 DIhL2b5dSS+enm7o/HVNjS1NejQyfQUWbCehOxUV+SORzs252UHJe6OKSXrKisELH9HF cjsQ== X-Gm-Message-State: AOAM532+fiO6nRudyFBWqvh2VjoeBfvtqtcvw8LN60h3ggPwhsfOC+ZT 8gZx5284JBzaRJZ19YCmDaCeeJryDj3WQnJU3C6clA== X-Received: by 2002:a92:d2ce:: with SMTP id w14mr1628816ilg.182.1610067350828; Thu, 07 Jan 2021 16:55:50 -0800 (PST) MIME-Version: 1.0 References: <765f86ae-7c68-6722-c6e0-c6150ce69e59@amd.com> <20201211225542.GA30409@ashkalra_ubuntu_server> <20201212045603.GA27415@ashkalra_ubuntu_server> <20201218193956.GJ2956@work-vm> <20201218195641.GL2956@work-vm> <20210106230555.GA13999@ashkalra_ubuntu_server> <20210107013414.GA14098@ashkalra_ubuntu_server> <20210107080513.GA16781@ashkalra_ubuntu_server> <20210108004756.GA17895@ashkalra_ubuntu_server> In-Reply-To: <20210108004756.GA17895@ashkalra_ubuntu_server> From: Steve Rutherford Date: Thu, 7 Jan 2021 16:55:14 -0800 Message-ID: Subject: Re: [PATCH v2 1/9] KVM: x86: Add AMD SEV specific Hypercall3 To: Ashish Kalra Cc: "Dr. David Alan Gilbert" , "Singh, Brijesh" , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Joerg Roedel , Borislav Petkov , "Lendacky, Thomas" , X86 ML , KVM list , LKML , "dovmurik@linux.vnet.ibm.com" , "tobin@ibm.com" , "jejb@linux.ibm.com" , "frankeh@us.ibm.com" , "Grimm, Jon" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 7, 2021 at 4:48 PM Ashish Kalra wrote: > > > On Thu, Jan 07, 2021 at 01:34:14AM +0000, Ashish Kalra wrote: > > > Hello Steve, > > > > > > My thoughts here ... > > > > > > On Wed, Jan 06, 2021 at 05:01:33PM -0800, Steve Rutherford wrote: > > > > Avoiding an rbtree for such a small (but unstable) list seems correct. > > > > > > > > > > I agree. > > > > > > > For the unencrypted region list strategy, the only questions that I > > > > have are fairly secondary. > > > > - How should the kernel upper bound the size of the list in the face > > > > of malicious guests, but still support large guests? (Something > > > > similar to the size provided in the bitmap API would work). > > > > - What serialization format should be used for the ioctl API? > > > > (Usermode could send down a pointer to a user region and a size. The > > > > kernel could then populate that with an array of structs containing > > > > bases and limits for unencrypted regions.) > > > > - How will the kernel tag a guest as having exceeded its maximum list > > > > size, in order to indicate that the list is now incomplete? (Track a > > > > poison bit, and send it up when getting the serialized list of > > > > regions). > > > > > > > > In my view, there are two main competitors to this strategy: > > > > - (Existing) Bitmap API > > > > - A guest memory donation based model > > > > > > > > The existing bitmap API avoids any issues with growing too large, > > > > since it's size is predictable. > > > > > > > > To elaborate on the memory donation based model, the guest could put > > > > an encryption status data structure into unencrypted guest memory, and > > > > then use a hypercall to inform the host where the base of that > > > > structure is located. The main advantage of this is that it side steps > > > > any issues around malicious guests causing large allocations. > > > > > > > > The unencrypted region list seems very practical. It's biggest > > > > advantage over the bitmap is how cheap it will be to pass the > > > > structure up from the kernel. A memory donation based model could > > > > achieve similar performance, but with some additional complexity. > > > > > > > > Does anyone view the memory donation model as worth the complexity? > > > > Does anyone think the simplicity of the bitmap is a better tradeoff > > > > compared to an unencrypted region list? > > > > > > One advantage in sticking with the bitmap is that it maps very nicely to > > > the dirty bitmap page tracking logic in KVM/Qemu. The way Brijesh > > > designed and implemented it is very similar to dirty page bitmap tracking > > > and syncing between KVM and Qemu. The same logic is re-used for the page > > > encryption bitmap which means quite mininal changes and code resuse in > > > Qemu. > > > > > > Any changes to the backing data structure, will require additional > > > mapping logic to be added to Qemu. > > > > > > This is one advantage in keeping the bitmap logic. > > > > > So if nobody is in favor of keeping the (current) bitmap logic, we will > move to the unencrypted region list approach. Sounds good to me. > > Thanks, > Ashish