Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1496707rbb; Mon, 26 Feb 2024 11:04:22 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUkfDQdEjNxlpaDa9WI2F6B2QW/Wl/zQ95+iL31llt+KGVkWOaOaq1XGoUEdClvQm8BJi80gaRILIwNcpf59GNflR6wREBNY+bXGwkNRQ== X-Google-Smtp-Source: AGHT+IGH8AzSHGgqQIBwY7RMpMQ9azsuP+LxLV7+0Zn8hwMl07WyUVIN6LK3NMDyRENvadzr+GEQ X-Received: by 2002:a05:6a00:3c86:b0:6e4:8b92:9a40 with SMTP id lm6-20020a056a003c8600b006e48b929a40mr9055400pfb.16.1708974262553; Mon, 26 Feb 2024 11:04:22 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708974262; cv=pass; d=google.com; s=arc-20160816; b=Utkq5WQhLm1q3TEVptXir+MM7rpLz2zvhe25NTzRJZOmF/UYBQWc2UjG2nyWS18dQD 3DCH7rc6IPW9ERyjf3k1ZrDxMsDJkzPILmjaESuBw9TSBUePVCTNthzNs4ZFfmLsTRrN 1woCFChwvD0qXWkrJpal+D3rPhlNUaDaERdrZrZtp6l23FYcIwh5SsNIdAERfTP2hh+s zoa5OJhruM7Nyi0UlPhgpvVSIoIZ88eE/jY1nm34AmkpKNeWNThGkzG7x8rWbHBVQstD a4R7bVWfJYofGYWC1VYXEgVNBuMz8TagVx8ofg+eXYWQICdIl9+JiFGtiyu7KAxfnTmo njQQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=/9RYhzIp/TSoYRODHKhiSBAhYa7Kz0V7a3mnNRHaZ14=; fh=TLdZJsFzSA0fpm6Q4iUv+uB0sG0oU+h3Bp6HiSGyZm8=; b=Ft/CsaInJRx9OJdceYsca9lO8fO0aRvHPo+O2sHApSDXd3v/p/jVb22VJRVk3f2Ao/ XokccQJ9Ivo9j2ofEXZSi3ykeJwjS4dgYhhOGPNsp5d0wveLU9p9m1KrDWKgt1PWSow1 7VEMdoIsj7E+enQRzWOYgx0mWiYNGh/xDRvHFGBOGy/nb6HEGPgVj2aFui9BXx1SBeDF b0GbMUI5UKE77I+i4ngZ+92LChsLyOXLTs/3GlSRa47X+Z5T9K/x9CKSLv1NDPHHHFu0 e+sQTsxgRo2sGwdOZuerF0zKe62LR4wTEOdaJfcB/EEC8n6f5wXjn9+Yq1a24bCOIg7q xjkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EzQdKeVr; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-82182-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j24-20020aa783d8000000b006e47dc9d922si4124819pfn.138.2024.02.26.11.04.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 11:04:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82182-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EzQdKeVr; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-82182-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82182-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 4524928E9C9 for ; Mon, 26 Feb 2024 19:04:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29C16130ADB; Mon, 26 Feb 2024 19:03:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EzQdKeVr" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB15012F583 for ; Mon, 26 Feb 2024 19:03:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708974232; cv=none; b=CvPAl0iUEKTcXHER7yt/Ea/BXVoRIA5s31pj7nD7KlP6nqsMTyaEUodTSV8LpXbcz++AQBPVY6Ch+IIgVj/8WdO4jSy9cBa/yBiQevbLnXFxsLvovQNz6v0S3ulz40LeiXJ2CIIOj4yCB2fwsM6OywUV+wbm08OSpX7cTpGwTD0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708974232; c=relaxed/simple; bh=JP2AhCp0qhW1Bb/uQ0B1c8bqZUtYcKr6siTzy/oGLZg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=h2lZiVzEQG4crTk1yrt4oFBo4xeMIa9XceBueqlq/y2s7NbhE9zAPBbxaobug1QtvsMEibwdQuwki5hQOvJ92D8veDujAkpRqFV+2CD3Wz3KLUFH+oRzQ6NiBezFeP3w3Bi6U9rPc5P+QqGEVgSWBTHTQl/p3kUaQwpn1FDBcts= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=EzQdKeVr; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708974229; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/9RYhzIp/TSoYRODHKhiSBAhYa7Kz0V7a3mnNRHaZ14=; b=EzQdKeVrgoMr+Gckaf6xVbPKwA37YilCOE4AsCq1EEoA5AsZgobVNRaoF/dBHW4CJ3N3AW MEBvWIRfIXb/0UEdpE69rMHNO0UTOg4bjT7bhbkKELKTgjit490IoWD0aa/Yj1j1A/jtD3 JZW8GuLnEB/gIHtaAZA0Rk4IQkt6WpA= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-479-pkuqUmQqP12Cr7DiNuPSug-1; Mon, 26 Feb 2024 14:03:46 -0500 X-MC-Unique: pkuqUmQqP12Cr7DiNuPSug-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D4D133C14940; Mon, 26 Feb 2024 19:03:45 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD491492BC6; Mon, 26 Feb 2024 19:03:45 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, michael.roth@amd.com, aik@amd.com Subject: [PATCH v3 01/15] KVM: SEV: fix compat ABI for KVM_MEMORY_ENCRYPT_OP Date: Mon, 26 Feb 2024 14:03:30 -0500 Message-Id: <20240226190344.787149-2-pbonzini@redhat.com> In-Reply-To: <20240226190344.787149-1-pbonzini@redhat.com> References: <20240226190344.787149-1-pbonzini@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 The data structs for KVM_MEMORY_ENCRYPT_OP have different sizes for 32- and 64-bit userspace, but they do not make any attempt to convert from one ABI to the other when 32-bit userspace is running on 64-bit kernels. This configuration never worked, and SEV is only for 64-bit kernels so we're not breaking ABI on 32-bit kernels. Fix this by adding the appropriate padding; no functional change intended for 64-bit userspace. Reviewed-by: Michael Roth Reviewed-by: Sean Christopherson Signed-off-by: Paolo Bonzini --- arch/x86/include/uapi/asm/kvm.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h index ad29984d5e39..ef11aa4cab42 100644 --- a/arch/x86/include/uapi/asm/kvm.h +++ b/arch/x86/include/uapi/asm/kvm.h @@ -694,6 +694,7 @@ enum sev_cmd_id { struct kvm_sev_cmd { __u32 id; + __u32 pad0; __u64 data; __u32 error; __u32 sev_fd; @@ -704,28 +705,35 @@ struct kvm_sev_launch_start { __u32 policy; __u64 dh_uaddr; __u32 dh_len; + __u32 pad0; __u64 session_uaddr; __u32 session_len; + __u32 pad1; }; struct kvm_sev_launch_update_data { __u64 uaddr; __u32 len; + __u32 pad0; }; struct kvm_sev_launch_secret { __u64 hdr_uaddr; __u32 hdr_len; + __u32 pad0; __u64 guest_uaddr; __u32 guest_len; + __u32 pad1; __u64 trans_uaddr; __u32 trans_len; + __u32 pad2; }; struct kvm_sev_launch_measure { __u64 uaddr; __u32 len; + __u32 pad0; }; struct kvm_sev_guest_status { @@ -738,33 +746,43 @@ struct kvm_sev_dbg { __u64 src_uaddr; __u64 dst_uaddr; __u32 len; + __u32 pad0; }; struct kvm_sev_attestation_report { __u8 mnonce[16]; __u64 uaddr; __u32 len; + __u32 pad0; }; struct kvm_sev_send_start { __u32 policy; + __u32 pad0; __u64 pdh_cert_uaddr; __u32 pdh_cert_len; + __u32 pad1; __u64 plat_certs_uaddr; __u32 plat_certs_len; + __u32 pad2; __u64 amd_certs_uaddr; __u32 amd_certs_len; + __u32 pad3; __u64 session_uaddr; __u32 session_len; + __u32 pad4; }; struct kvm_sev_send_update_data { __u64 hdr_uaddr; __u32 hdr_len; + __u32 pad0; __u64 guest_uaddr; __u32 guest_len; + __u32 pad1; __u64 trans_uaddr; __u32 trans_len; + __u32 pad2; }; struct kvm_sev_receive_start { @@ -772,17 +790,22 @@ struct kvm_sev_receive_start { __u32 policy; __u64 pdh_uaddr; __u32 pdh_len; + __u32 pad0; __u64 session_uaddr; __u32 session_len; + __u32 pad1; }; struct kvm_sev_receive_update_data { __u64 hdr_uaddr; __u32 hdr_len; + __u32 pad0; __u64 guest_uaddr; __u32 guest_len; + __u32 pad1; __u64 trans_uaddr; __u32 trans_len; + __u32 pad2; }; #define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0) -- 2.39.1