From mboxrd@z Thu Jan 1 00:00:00 1970 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 71501C3DA7A for ; Thu, 22 Dec 2022 23:05:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230064AbiLVXFM (ORCPT ); Thu, 22 Dec 2022 18:05:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbiLVXFH (ORCPT ); Thu, 22 Dec 2022 18:05:07 -0500 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 187BD2717A for ; Thu, 22 Dec 2022 15:05:07 -0800 (PST) Received: by mail-pl1-x649.google.com with SMTP id c12-20020a170902d48c00b00189e5443387so2225900plg.15 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=LRb3JuWl9GcrwXmE6OsTpgNgwwriWw65XeGpKvTjU8XPlICqc7V+iDVoYsvAnqXOOQ AzWB4je0Mt58Xjhfeg3UygDPZlpj0n2DNysVA6wBAZFH6NPFGZYDaYCRybjbA3NfQxya jHNkvsN/xVYPXqomLGzEjr0zxGMSHMv60Db9tD81yc4vmhNZH5W8wmqjdvnbPJXzfcy+ qM1RTlJX+cES8ERNPENBXT9jpw4J6qy2RaAJATJo1FBgIM4rz6MKPZeecuiGBvqxwOdF IvVt6gJvtpIJrKvorvNqbQiMfmRPVMDw/f2GOQDFkRWcmSEgjE6kFQCm28O/CcAYjvZm 8HBw== X-Gm-Message-State: AFqh2kqhHhvnO9rwe6WkSdyJ6G+fzhThnYBaWqrPtjJRv0ZI8AMCzn3d fsxV73RYhA5s8+WU/kID8sKglc+863l0TyYm 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) -- 2.39.0.314.g84b9a713c41-goog