From patchwork Tue Apr 9 13:39:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Gonda X-Patchwork-Id: 13622527 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.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 B26D512FB2F for ; Tue, 9 Apr 2024 13:40:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712670017; cv=none; b=jdiNIM0cLnKmNlBVYlWW4JzTMlvko/sENRdbOu0zy3WBghwK3QXMzWS8ijRFueMuTfJvfAWCQ+MuNzZqkb1CwmerbAjfUBTEXeVAGPE3MoT2QL/V4fxdlXqvJPHBwnus1fowtwcHnhv8oVFtf7tHgPpo/9X3QelheG62uh+oSo8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712670017; c=relaxed/simple; bh=8YAynhoBcTZH25sdLVIb9gPxNYS9bVlziuWqHn3N3EE=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=CY8MbLsk3jUt0lJ9JKJZI48QGb+07WroJJZvoIOYaN8WeUoouDVpZDFE7BxP3aQM6mvcRCn5eMDIZ7TquT6VEfqTwlIXeta33wC1QdPffZylQiMHwwYfnmLh3+DAZn09T7j62/hMgJeF0aHnIVThL1QR+O4S9wqVYpf6SDuzXCc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--pgonda.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=TEGUOZZ5; arc=none smtp.client-ip=209.85.210.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--pgonda.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="TEGUOZZ5" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-6ea7f05b543so4063399b3a.2 for ; Tue, 09 Apr 2024 06:40:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712670015; x=1713274815; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=uMEfBjeMsB/RLCKigMRUoYsxAnS7VrosZGuO6YiswGs=; b=TEGUOZZ5SFJr7IV9lSgRfIUHw0VwRgQ2Q4MMll7rzmMFLWAX2m8VDxQxY39+SQXd6i UHDlCgdHDuxHddLC6GtWWlbctFnizXjPw7V90SnxdsU/FLD+XT22koVCFlgk3XBqjGd3 ZUPLu/lGGo6vG0IVzRbSxUyLMpuC6rm0rviKqv7p5GL86ooQ8bV38PKLnB4U43u8Hjgh p149YnqYgU7/qLXkzSbq3BWPlLPq4oocK5J2NLxsnMbaxN4prEpL5sawzbHFF38WLtzI k4vzjPoq4jzryBQFByWIAifhWxFeIt4TZHBQz03MXDOjQt3NGCJsZ8V0Zm1nE3SQ84Pg PtUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712670015; x=1713274815; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=uMEfBjeMsB/RLCKigMRUoYsxAnS7VrosZGuO6YiswGs=; b=Kxit4XjGrCKPDU0TyIEjqnAJ0TL7FRCDizV+5h1QcBPt6jN1DVWhd7vzLsQ36rlKJz T0tJHlNiLX653fD5o3sRVKYR3TLbEi4Yio6nEuYdiZEz5iu3z7FHFuleXRT8GxjjLinJ RSrAJmRsalZsjO/C3xgUxVBKOiK2ZXKiFe9H160sotA69ZO498Ip+D22u0JBLlNhL/5m 5Diwz3GbMBP84i+l2HNYaXF2kQiRsW1W1Gr56i4n88D2P+oqh6OW1CLoUg0jFnSJ36CE 0/zpICgDUNhQIcB2pEefwhZ8g0KC5TX543/uJpl3tkorTFvpASpJp2x26UOCxRzg0m2a /XCg== X-Forwarded-Encrypted: i=1; AJvYcCWgLfmw5ALRjsAHuspLNkcfoj3Q58CC1Ws2L0ImRkr0fqIfLVKNmqXatmzKS+6IQkcBiWoTWUmtwB0jkf9llxysMJG8u4I6PvMsNKEWIJ8R X-Gm-Message-State: AOJu0YyXIdiAzBbblniMvIZW7p8jBZbjlkXOAhBeuTUYnHhMPFpN/+w/ uvj+t9QMVx45YT6NDjrNT/UDFEp/srj0e/akCmZF6AvdAdn90nSKBAcTk0HfD0xNQiwnCkIntFv 9nA== X-Google-Smtp-Source: AGHT+IGRVEIRxXQ5a79kYy7qEqv4mC1lhc2zIbiG+1EbVkZiFBFly1NL20PHEOj07ifmpp84iSHWkw0p5zY= X-Received: from pgonda1.kir.corp.google.com ([2620:0:1008:15:661d:897e:ea86:704d]) (user=pgonda job=sendgmr) by 2002:a05:6a00:1828:b0:6ea:e2d9:f2af with SMTP id y40-20020a056a00182800b006eae2d9f2afmr1093312pfa.0.1712670014924; Tue, 09 Apr 2024 06:40:14 -0700 (PDT) Date: Tue, 9 Apr 2024 06:39:53 -0700 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.478.gd926399ef9-goog Message-ID: <20240409133959.2888018-1-pgonda@google.com> Subject: [PATCH 0/6] Add initial GHCB support for SEV-ES selftests From: Peter Gonda To: pgonda@google.com, seanjc@google.com Cc: linux-kernel@vger.kernel.org, Vishal Annapurve , Ackerley Tng , Paolo Bonzini , Claudio Imbrenda , Carlos Bilbao , Tom Lendacky , Michael Roth , kvm@vger.kernel.org, linux-kselftest@vger.kernel.org Adding GHCB support for selftests. Very similar code to the ucall functionality, I didn't refactor anything common out since I was unsure with just two instances that is required. If pulling out common code between those two is preferred please let me know. The series only adds a single usage of the GHCB which is a special outsb GHCB exit to allow for passing the 64-bit ucall pointer. In future series we can test more GHCB functionality of KVM. I'd like to base some SNP smoke tests off of this and the current SEV selftest work. base-commit: 40e09b3ccfacc640d58e1e3d6b8f29b2db0a9848 Cc: Vishal Annapurve Cc: Ackerley Tng Cc: Paolo Bonzini Cc: Claudio Imbrenda Cc: Sean Christopherson Cc: Carlos Bilbao Cc: Tom Lendacky Cc: Michael Roth Cc: kvm@vger.kernel.org Cc: linux-kselftest@vger.kernel.org Signed-off-by: Peter Gonda Peter Gonda (6): Add GHCB with setters and getters Add arch specific additional guest pages Add vm_vaddr_alloc_pages_shared() Add GHCB allocations and helpers Add is_sev_enabled() helpers Add ability for SEV-ES guests to use ucalls via GHCB tools/testing/selftests/kvm/Makefile | 2 +- .../selftests/kvm/include/kvm_util_base.h | 4 + .../selftests/kvm/include/x86_64/sev.h | 7 + .../selftests/kvm/include/x86_64/svm.h | 106 +++++++++++++ tools/testing/selftests/kvm/lib/kvm_util.c | 22 ++- .../selftests/kvm/lib/x86_64/processor.c | 8 + tools/testing/selftests/kvm/lib/x86_64/sev.c | 149 ++++++++++++++++++ .../testing/selftests/kvm/lib/x86_64/ucall.c | 17 ++ .../selftests/kvm/x86_64/sev_smoke_test.c | 22 +-- 9 files changed, 313 insertions(+), 24 deletions(-)