Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp1146992rdb; Fri, 9 Feb 2024 11:40:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IGquUtzRi9MqCL1mlcLQG07tOUh+4Y9GaOtwSAXj2Juuk9sWgMXVrImoFYv9aQk0ilmL1/F X-Received: by 2002:a17:906:80c:b0:a38:8d35:c8b4 with SMTP id e12-20020a170906080c00b00a388d35c8b4mr36097ejd.46.1707507625063; Fri, 09 Feb 2024 11:40:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707507625; cv=pass; d=google.com; s=arc-20160816; b=jAJ7rT1YsJwuSkS4eQRNik4GbzTXT3IlSdpaH81zANgruQOCh/gvytZFRWrgIObtXp vCPQ/8kbvGWfl6ifcrvbPw0XG4AsdEZR7gD0zukGNyAE6c+YrmSW/oH+vXvsqiDJ4hg2 m535nCvCUDaBXxtSIs4NVqfa6ZefIBIDQmg8tLoUSNWZsvcdQaL3PoUcnwCRYL02SYoL OXr/QEoHZvl2msvx3jKuna/IwdrVhHHlDaU19tb01/paIvZK/LVRrNLNX+OhGusOjt2K MbQ7Y9e53t3j4MMGMFBJa8xGSpBXHAp1tpZvuig+B/oB1Xhm7XbuZ6G3c6o2b/i+G32l TnNA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :dkim-signature; bh=17oyzkB4xEUSVt+DktGPEZwkZ62rQj4myNkqahQjvb0=; fh=Uq3yAk2eJJTMCmEKqrsNg7/cE+I1DHuIZ02QmbLRkfQ=; b=PAP+mQw8xTvpJ2Q+lEB6ZSroBGc0edZNJw+Bw7v2GyuJqFLHBla3z+64gsNyyT32Mb Sg8LlNDW2Z37oGpaLyp13daeVbfbl4X6JB6NRAKLJxnIE5HzqVSz9b6XJ9EP1ckowD9Q quypY5LryeQGjH70Zf23nNDAXlNt/3BiP6PJkp5krK8wEqnTLxeej5FIxB6PNlIZiUdV TxcavdCXDvFhLBk+9M3xvefuByu00mZrqRplC5SQVydCHFYk6W9Yl+u7eYfE9XGqaKJ3 CeSxae1fbH39fz65PO4oNZYGDESw3rwmF/4srwPclEpqzQOxpOpxfO30LpePF8dPvr3h 3HPg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YpTFkfk9; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-59894-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59894-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=2; AJvYcCXA6q/IJKmpvtEHEx5we63em1CqhQquk8LSfJR3XDJc4p8/SrfzNZIPzv7Ttn5sLUvy/Ir/vPNhnuyUH3/86y5FkFE3jXCdQMXO1/uTWw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id qw9-20020a1709066a0900b00a3beef865a3si972842ejc.303.2024.02.09.11.40.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Feb 2024 11:40:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-59894-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YpTFkfk9; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-59894-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-59894-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CEDB31F22F53 for ; Fri, 9 Feb 2024 19:40:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A5EF984A2A; Fri, 9 Feb 2024 19:40:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YpTFkfk9" Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6275382866 for ; Fri, 9 Feb 2024 19:40:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707507615; cv=none; b=l0386nLFj9YXzBshHKl+rwaTiLmd8FYro3q4nGNvrQYY0a9EY98eDVDVXSKs7fXR5QR3rdGTj7GSQVJL95SmwPiScfP25111GGoferrGMNBSiTVOvGTEHM/VU+2doK2PBMgEgA8smYcwgwVN56WsHofAOWjGpcvsF8laW5RRbdQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707507615; c=relaxed/simple; bh=6PPQOnkkIeCfd/CHcSpaIXnSwRon/6R8zai/0r9L2sA=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=qTJNL7PJre4DxJG956Y4n/mG4FJxeefP7i0Ur8ilf/GDRHODcT6k8L82eNAYa/OM2Bjd8wFw7c2ujJJX6ORtxdsj+KfMFvB65EkkhIbK9HDs3FyicbTZ8PinnC+3fU3+em9eebzOXqvMGkzgob1rJT2+lG3S9M36UETLAYcxce4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=YpTFkfk9; arc=none smtp.client-ip=209.85.215.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-5cf2714e392so1308211a12.0 for ; Fri, 09 Feb 2024 11:40:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1707507613; x=1708112413; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=17oyzkB4xEUSVt+DktGPEZwkZ62rQj4myNkqahQjvb0=; b=YpTFkfk9LE7LjXC30X+m/dcf4SKqGoSU+mC6LyKn1tjdv+XBKoYvYjgpoKb4vV6p+j CAS6wv2BB5TK61nxl/bL6QeqUIrLgTZiR+fA+v7FOHln4NSm7i57XlbT//4IGFMF2Cs7 q+y83+WhAgqeCRN81P/7DUSoZtod1uDmoQgLuH5+/0igKR6cUc8kVXrLWOKlodhRcpPs CESUlWlbqxp0qye6JpI/RfHjx/7Cz1SE3bg2fHvqdH/nZrTMITgOUkJPdTYomMLXrym7 IDnGRPR14om7MR0asbiMnJZba9Lv+a3rVvYG9UQDI7IVVRMXEbiqxPPRw7C7G/A840HM LC+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707507613; x=1708112413; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=17oyzkB4xEUSVt+DktGPEZwkZ62rQj4myNkqahQjvb0=; b=sJuY7ZKwJr+C6Q3QH4/fq2YdEgjmntJIVuS/0Cuy48zwOR+Clytee5PhB1NAprz12T uAtyPSa6d+H59goq6niNCCRFVJsk/7GYYECQznL+D8JuyO9d+Cp0JO53LYLyYWXVi0OX 6jjMZh04GNyfRM4E6YCRktkUwjqCSx0hE4bMkwelZLsQEHy1hmitJ7VK/fcw1C3IFHvT jRnmYwaWhqstprOLuOBlFnORS+ikcHTzSZ0AL0ivKdiFC5iykAO1jcE+0Z9AgishXB1R 7I7W0BsHZqF3XJ1bNO+Lm5ickZuiGTGcMaF20v7frUkSNZyvZYMPqjOPX1DYIAmL82g7 q57A== X-Gm-Message-State: AOJu0Yzx/xpKLAwdJVOS/uHkDlHdsLDsi5fvAcElFxUpsOdBBu9Qgskt laKEqnQwwgBunVhUa7O+0bWMz5CbjxqyHbChJ7tyi53dQw6GXopjjRgYeSh1lDVo4/hole2GkzS gyg== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6a02:305:b0:5dc:19c9:d794 with SMTP id bn5-20020a056a02030500b005dc19c9d794mr1603pgb.0.1707507613300; Fri, 09 Feb 2024 11:40:13 -0800 (PST) Date: Fri, 9 Feb 2024 11:40:11 -0800 In-Reply-To: <20240209183743.22030-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240209183743.22030-1-pbonzini@redhat.com> Message-ID: Subject: Re: [PATCH 00/10] KVM: SEV: allow customizing VMSA features From: Sean Christopherson To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, michael.roth@amd.com, aik@amd.com, isaku.yamahata@intel.com Content-Type: text/plain; charset="us-ascii" On Fri, Feb 09, 2024, Paolo Bonzini wrote: > The idea that no parameter would ever be necessary when enabling SEV or > SEV-ES for a VM was decidedly optimistic. That implies there was a conscious decision regarding the uAPI. AFAICT, all of the SEV uAPIs are direct reflections of the PSP invocations. Which is why I'm being so draconian about the SNP uAPIs; this time around, we need to actually design something. > The first source of variability that was encountered is the desired set of > VMSA features, as that affects the measurement of the VM's initial state and > cannot be changed arbitrarily by the hypervisor. > > This series adds all the APIs that are needed to customize the features, > with room for future enhancements: > > - a new /dev/kvm device attribute to retrieve the set of supported > features (right now, only debug swap) > > - a new sub-operation for KVM_MEM_ENCRYPT_OP that can take a struct, > replacing the existing KVM_SEV_INIT and KVM_SEV_ES_INIT > > It then puts the new op to work by including the VMSA features as a field > of the The existing KVM_SEV_INIT and KVM_SEV_ES_INIT use the full set of > supported VMSA features for backwards compatibility; but I am considering > also making them use zero as the feature mask, and will gladly adjust the > patches if so requested. Rather than add a new KVM_MEMORY_ENCRYPT_OP, I think we should go for broke and start building the generic set of "protected VM" APIs. E.g. TDX wants to add KVM_TDX_INIT_VM, and I'm guessing ARM needs similar functionality. And AFAIK, every technology follows an INIT => ADD (MEASURE) * N => FINALIZE type sequence. If need be, I would rather have a massive union, a la kvm_run, to hold the vendor specific bits than end up with sub-sub-ioctls and every vendor implementation reinventing the wheel. If it's sane and feasible for userspace, maybe even KVM_CREATE_VM2? > In order to avoid creating *two* new KVM_MEM_ENCRYPT_OPs, I decided that > I could as well make SEV and SEV-ES use VM types. And then, why not make > a SEV-ES VM, when created with the new VM type instead of KVM_SEV_ES_INIT, > reject KVM_GET_REGS/KVM_SET_REGS and friends on the vCPU file descriptor > once the VMSA has been encrypted... Which is how the API should have > always behaved. +1000