From patchwork Thu Dec 22 23:04:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Annapurve X-Patchwork-Id: 13080426 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AE52C3DA7A for ; Thu, 22 Dec 2022 23:05:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229868AbiLVXFK (ORCPT ); Thu, 22 Dec 2022 18:05:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbiLVXFH (ORCPT ); Thu, 22 Dec 2022 18:05:07 -0500 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 173C827176 for ; Thu, 22 Dec 2022 15:05:07 -0800 (PST) Received: by mail-pj1-x1049.google.com with SMTP id b16-20020a17090a551000b00225aa26f1dbso1648613pji.8 for ; Thu, 22 Dec 2022 15:05:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=tHWaMPgNH1Gc3dyUgtUp96T2Ds+DtSztVEOEp9eXXLE=; b=J1m6H/8q08TJDo6V440ml0vH1FPML4rBgC8Z8KKPyy9b9/w8p2/vuVbFAcP5/BIAJ4 8g2gBZHdZ0kkBZpuRDrDBf6PK5MKrygPfkntIl+QYO7R3SsdNqtM7zMJJFD+QQT7Vf3O cZzYsjv9ugcbYt1JdD/7UhuGjKi2sO0roV3kbzu1WamewDTwrz4UtKcNrevBr7fZqtH/ NFIWVwfuajUEi3u4L8ZDM7NCHNFAgx1b6x/mJ97l9sH5BMg4X0cRKjU9Mb8VFKkwMYvx lpO9dvk7LHv4xWvbOnlwithG5+PhG/ySqI8EUDrlzxI313a5QmjtI0xcWfwjMLYPijgz TS3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=tHWaMPgNH1Gc3dyUgtUp96T2Ds+DtSztVEOEp9eXXLE=; b=k0bI+3BGwFqKxwqSdxVBt1AXwePd4uyHZvScaQFRyqYcJE4jVvu1kGOhWM2SF6JPIy fH8ZcZG+NNrn1azvIAyfKvXgGIOzDS2OuzcHrhhlpSCqlxRtqq0gC9DQwsk06+rkx941 jUb9vzoCjrsYVNS6BOx6dYYLBQ64ffD/p585KZx6AaThgR2H7gMwvcPlcTzfopyD1hEm U4nwfQpssrYTAUJHw3YfpTb1W/J3dAXt7JngMcpd65KKZ+zI6i7px4Ai3veDt/7IAiZl iQ6EpY24r9bLvQc8mIUC6s5FwAbFcZrBwKc3jxttq/HSvK8ojh+WLQSCuZsuaG2leTMQ uEiw== X-Gm-Message-State: AFqh2kqRmwVx9dgJTw98iG6SZwu7QawhgKJwW6po76zdpBTlQC6DyYNd o6Q1FsKm6bqT1pEPC5aTS+tU47eJhHOTDWIu X-Google-Smtp-Source: AMrXdXvwYXr/36+Tv89Q0SjDNBpV9g/udTWdh/80BGWKMaCWt/H1422BELxbkBKJEg7hprGc87A0aX+OAgBKgpj6 X-Received: from vannapurve2.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:41f8]) (user=vannapurve job=sendgmr) by 2002:a17:90a:d350:b0:223:fa07:7bfb with SMTP id i16-20020a17090ad35000b00223fa077bfbmr675609pjx.38.1671750306569; Thu, 22 Dec 2022 15:05:06 -0800 (PST) Date: Thu, 22 Dec 2022 23:04:56 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20221222230458.3828342-1-vannapurve@google.com> Subject: [V3 PATCH 0/2] Execute hypercalls from guests according to cpu From: Vishal Annapurve To: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Cc: pbonzini@redhat.com, shuah@kernel.org, bgardon@google.com, seanjc@google.com, oupton@google.com, peterx@redhat.com, vkuznets@redhat.com, dmatlack@google.com, pgonda@google.com, andrew.jones@linux.dev, Vishal Annapurve Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Confidential VMs(CVMs) need to execute hypercall instruction as per the CPU type. Normally KVM emulates the vmcall/vmmcall instruction by patching the guest code at runtime. Such a guest memory manipulation by KVM is not allowed with CVMs. This series adds support of executing hypercall as per the native cpu type queried using cpuid instruction. CPU vendor type is stored after one time execution of cpuid instruction to be reused later. Changes in v3: 1) Guest logic is modified to not rely on host cpu type and instead query cpu vendor using cpuid instruction. 2) Existing callers of vmmcall/vmcall are not updated to avoid enforcing native hypercall instruction across all users which are mostly non-confidential usecases. v2: https://lore.kernel.org/all/20220915000448.1674802-1-vannapurve@google.com/ More discussion around this change: https://lore.kernel.org/lkml/Y1Hhw40H58EmZ6lK@google.com/ Vishal Annapurve (2): KVM: selftests: x86: Cache the cpu vendor type KVM: selftests: x86: Add native hypercall support .../selftests/kvm/include/x86_64/processor.h | 3 ++ .../selftests/kvm/lib/x86_64/processor.c | 51 +++++++++++++++++-- 2 files changed, 49 insertions(+), 5 deletions(-)