From patchwork Wed Jan 31 23:56:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 19763 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp100336dyc; Wed, 31 Jan 2024 15:57:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IE326nj0FW3uGoyqDsPbZacHqQYNdlby9p/GyRzTK/fhPKyAzQvutV3zH6up+Nl9wclcuVW X-Received: by 2002:a05:620a:6182:b0:784:853:4003 with SMTP id or2-20020a05620a618200b0078408534003mr1246000qkn.4.1706745423540; Wed, 31 Jan 2024 15:57:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706745423; cv=pass; d=google.com; s=arc-20160816; b=dFJwvjZhLLsxDx/Y14qcG4sgONwwQzTQq8VDucDbCi58fceIaZ/lF9B++GJwhHlzck ISR0NnpTvZDJodg+ZSb2yGVnYQNeaw/JnNlLneDBOUGc89yqY9OmecqYSv3GkTQ0MY5T DGHnpCnwt44Cy/VSChqxAtYLWg+qUhTGty9MDNU9rYJ+DqR5BlHqDCl+B7HLgK4mqWYZ NUqyU1Btv4Da8vYUDfGPOfvjeFYpAXIUgEgZXXtf7t6T5QyrTyrQ/7viULF2MNiwGVul Ek+tE4fczHj5fW7lvioXbQdSqmPgfyYStaD5Qfzb7G+DoPi0msD3doSxIi2FcaS0ddbo /jvw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:reply-to:dkim-signature; bh=K8FMEPE2YDBac9DHbaO7Tj79lmJ6nt9ZY1wWZ4fnjeI=; fh=XJ5sg9o5MZvHS8a1XSIpL9Xss9hrHJEwUDKd6yT4MCM=; b=wCyuawU8NhI7uYFRnT6N50Q9vbCHnMooK5N0MsqStl2YWeGLHKIrUG4zORxW6VYKxy 7iiiAuAe+7ADCguMPr6tQliqjF7QmqLaPiXpuLYKUqpIjtl3DDrb1mAp8CbkX1NQiimv sv61wW2PKGTb31ECSljW5mdE/4tCIMysKljX2eMYixUGMAuSZR/nVEOZ+cSWeGOQklVz fQXXPpDWBXffg9v/X5b+HTpBE7KJsnAK3qFlvqUVhbJ/eLCPejhVHOuALGghVVkuDlju niwbUCcr3hzXpxBkqR6Ltv5pHLJ6aB/iRVp2qRZ0Tm/sn8KjkqrCt5QxjxMzSyAfILBO bdXg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ZtBJ847A; 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-47399-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47399-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCUUTokMHC8GpozIFs6WPR/NeVioDETj67wLj09v+NH/BAtXwHqEHb4u/2lLQ43ll2do1f6dM/XQtDuzUnVzvVLowGynpg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id k3-20020a05620a07e300b00783926eac1fsi12784711qkk.637.2024.01.31.15.57.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 15:57:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47399-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ZtBJ847A; 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-47399-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47399-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E702B1C227E3 for ; Wed, 31 Jan 2024 23:57:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1217E3CF47; Wed, 31 Jan 2024 23:56:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZtBJ847A" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 8A3783A8EF for ; Wed, 31 Jan 2024 23:56:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706745374; cv=none; b=s0aRhu41WWD2ZLyGnEcFeK+2J5lrEQgI27n/flB8g01/OADOuJLudzeNWAAOI++A/0N9JzOKcgnBz4r6gk/A/9D1IDNicKGywfXTQWkHkuZT2oUaVUBduLPGG80ZgmcyCGur2XKkLh6VFfVXHhWsOxlLlUsl8g/Wvyq3G+OQSIE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706745374; c=relaxed/simple; bh=KskMSvoey6KMBFSjef9AcR9PGosR1vFfg/lPVD0dxa4=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=kWJ+ftsLopM5NAgNBY5fEO7OtbjK3iAZWtREVZvW1lSbqzH5XZSQK56KLvje01mdO5i2oL5gXhYhzTXGDziUa6VE0yawyFHa1bxxVHHBRe1AKEJ7dq0trMJHNNpZ8loYK96m/7x0KxfIKye/siZYjogAAQdE7CS055W0/sH4x+I= 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=ZtBJ847A; arc=none smtp.client-ip=209.85.219.201 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-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc6ceade361so576446276.0 for ; Wed, 31 Jan 2024 15:56:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706745371; x=1707350171; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=K8FMEPE2YDBac9DHbaO7Tj79lmJ6nt9ZY1wWZ4fnjeI=; b=ZtBJ847A4ZeheQYv3IMXOYHZFVfgkFqjss4OZ0BTyaIOjDaKQBhBYnXRHoRdQE1JX3 1SZBQ+Z3T78WEJaWaY6qytK6DGzSXQbT64E2OvSvApkRG4EuRJz4NwQZUogkhbcCxgF3 eHIoLYH7Qx8YDyLJFrFdVCzj0BNZEiuOu7uQdX0hXuyoN/XvUOl4QJ3hcMMo1TDz/xNf HG88cEsZeNYiizSv9nebxFhhcVCf4kXzSddloUw/vQbLArMym+4XmmJOJRS/TarEMzjH znVOLZT/eC6JmgE2IxJ0vUXf2MKRkzF8U4s5Bp1udIdf9pWvlUcyLlRK/OCpvQf0TOPC bNZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706745371; x=1707350171; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=K8FMEPE2YDBac9DHbaO7Tj79lmJ6nt9ZY1wWZ4fnjeI=; b=qz5uU302rPcZSmpGEZPt1ez3eKWT8z5rJqD2az8BOj9/Mla99xW7PDwrSud2K9TZlO QDu4VE4OO5KFNQo66k7zAiirx/VI5lzknX3llALa+cMVowTptWJ8S3YPGe8dSnrW7PDx UIwy+NqF/sNf4uR/BObrWKkSR5zJt8Lq/jiS2Os9/o1bl5vqiP+0Lh5xm/1plZ8ck02/ QyQ0FBjXWiV1imlFGvzzlWk6cBu7kYfLFSX7Kdh8rJEK/Ad8W4ESyKv1+jwHjcLiXta8 TyQYSsb7XoACTyqto6lOZuJCmJZabQ1IIfzgvchgdWAXKjJTqKmMqbzu4PfirnZtC/ul T13w== X-Gm-Message-State: AOJu0YwhqUZ3Qb/mfImrT8VcIw8HY1BErNcCezrVj3Sd+8iX9HpxuKji vtFpMjbpxnwTt/vEhocgKvmUJF/kb47VPJGt6Ml8D5lWE8GEmiUPonGu4DEcWHVT88UkcyXvJ9f 2ZQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a25:1c5:0:b0:dc6:d2c8:6e50 with SMTP id 188-20020a2501c5000000b00dc6d2c86e50mr281905ybb.7.1706745371641; Wed, 31 Jan 2024 15:56:11 -0800 (PST) Reply-To: Sean Christopherson Date: Wed, 31 Jan 2024 15:56:05 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240131235609.4161407-1-seanjc@google.com> Subject: [PATCH v4 0/4] Add support for allowing zero SEV ASIDs From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Ashish Kalra , Tom Lendacky X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789652289143193178 X-GMAIL-MSGID: 1789652289143193178 Play nice with systems where SEV and SEV-ES are enabled, but all ASIDs have been carved out for SEV-eS, i.e. where actually running SEV guests is impossible. v4: - Convert all ASID usage to unsigned integers. - Clean up sev_asid_new() so that it doesn't needlessly overload its return value. - Split out the -EBUSY=>-EINVAL change to a separate patch. v3: https://lore.kernel.org/all/20240104190520.62510-1-Ashish.Kalra@amd.com Ashish Kalra (1): KVM: SVM: Add support for allowing zero SEV ASIDs Sean Christopherson (3): KVM: SVM: Set sev->asid in sev_asid_new() instead of overloading the return KVM: SVM: Use unsigned integers when dealing with ASIDs KVM: SVM: Return -EINVAL instead of -EBUSY on attempt to re-init SEV/SEV-ES arch/x86/kvm/svm/sev.c | 58 +++++++++++++++++++++++++----------------- arch/x86/kvm/trace.h | 10 ++++---- 2 files changed, 39 insertions(+), 29 deletions(-) base-commit: 41bccc98fb7931d63d03f326a746ac4d429c1dd3