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 X-Spam-Level: X-Spam-Status: No, score=-7.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A3EBC433B4 for ; Tue, 18 May 2021 10:59:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 74B5A61261 for ; Tue, 18 May 2021 10:59:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348689AbhERLBM (ORCPT ); Tue, 18 May 2021 07:01:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22716 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348192AbhERLBK (ORCPT ); Tue, 18 May 2021 07:01:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1621335592; 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=hMetlmNBWaKkSQsHWQlPS1UZ381FEjltyXsY7/tZa1o=; b=UuEAQokTZai6HOtbJhBpS0tZUPe6C2AQ6HVIg9YqPQlEqnkqP44LwfA85texkfJTC2M8M/ pCKc7Tarv2bb6vEGbE7AipcCuBKfRnaKyCRV1KmKjR5VP0UQvBhoa4rbD4wczhxLZo+t+Q BaEfFVVL2zoaVvJG05s08y8yrYwrbZM= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-371-cO0sGUV0NVey1gJJRxHxwg-1; Tue, 18 May 2021 06:59:49 -0400 X-MC-Unique: cO0sGUV0NVey1gJJRxHxwg-1 Received: by mail-wr1-f71.google.com with SMTP id 22-20020adf82960000b02901115ae2f734so5420942wrc.5 for ; Tue, 18 May 2021 03:59:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=hMetlmNBWaKkSQsHWQlPS1UZ381FEjltyXsY7/tZa1o=; b=CYJInE2FKMcsLISHhPR/yWCi886Y6zOCdhIsJk9NLS6f9J/1mKWAnWuy95syBdmYM8 bJvsEO+fm9ZE57VDBq2tMCzZql4N/C7Qe21+MWr3B4mLb4EFrmEZflQqlDbaTVs1DqnC bbXHRk7xmcXk4FOrMdfLbKpqr+rILnP3Hdi8y4Qoq8mD0EVIdk4fRlU2VB0rslMmWbCW 5hK0CwwhNHdvPlHeJW5P8zxAN3hzWoZ1oENIniDf/Dotf1fSNSsx+dPvtU3BEX693ewA uITUK1g/WAkfnjp/SI1nk+ra0uIlIhn2GlPfe8zb4tZ26d7IPgFvAtEbGTNFvXmNFC6U nQUQ== X-Gm-Message-State: AOAM5319MqK8XJRWzB3zwocBtB0gWKYJec00us8Fizo52GyGWbRufBM6 8yFoHdcO953aKXtu48Q5YROAOp1xl1GYA2NIhJbdPL9GXDHNX/Ny2wMaj0fb05DcMXF3w2Hh/i1 uW6GY9F5r4TVMLfFwWmr3z++D X-Received: by 2002:a1c:a7c2:: with SMTP id q185mr4773583wme.112.1621335588450; Tue, 18 May 2021 03:59:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxllCecXZGTpo+tx3njY/mjs6yhhjT7+AqQP3UBaqDnyvze9lTSIc9uLbe6ZeMkLFhxkbOrw== X-Received: by 2002:a1c:a7c2:: with SMTP id q185mr4773567wme.112.1621335588276; Tue, 18 May 2021 03:59:48 -0700 (PDT) Received: from ?IPv6:2001:b07:6468:f312:c8dd:75d4:99ab:290a? ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id p14sm21023492wrm.70.2021.05.18.03.59.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 May 2021 03:59:47 -0700 (PDT) Subject: Re: [PATCH 03/15] KVM: SVM: Inject #UD on RDTSCP when it should be disabled in the guest To: Sean Christopherson , Maxim Levitsky Cc: Jim Mattson , Vitaly Kuznetsov , Wanpeng Li , Joerg Roedel , kvm list , LKML , Xiaoyao Li , Reiji Watanabe References: <20210504171734.1434054-1-seanjc@google.com> <20210504171734.1434054-4-seanjc@google.com> <1b50b090-2d6d-e13d-9532-e7195ebffe14@redhat.com> <4a4b9fea4937da7b0b42e6f3179566d73bf022e2.camel@redhat.com> From: Paolo Bonzini Message-ID: <1245ad2f-78b2-a334-e36a-524579274183@redhat.com> Date: Tue, 18 May 2021 12:59:46 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/05/21 18:56, Sean Christopherson wrote: > On Mon, May 10, 2021, Maxim Levitsky wrote: >> On Tue, 2021-05-04 at 14:58 -0700, Jim Mattson wrote: >>> On Tue, May 4, 2021 at 2:57 PM Paolo Bonzini wrote: >>>> On 04/05/21 23:53, Sean Christopherson wrote: >>>>>> Does the right thing happen here if the vCPU is in guest mode when >>>>>> userspace decides to toggle the CPUID.80000001H:EDX.RDTSCP bit on or >>>>>> off? >>>>> I hate our terminology. By "guest mode", do you mean running the vCPU, or do >>>>> you specifically mean running in L2? >>>>> >>>> >>>> Guest mode should mean L2. >>>> >>>> (I wonder if we should have a capability that says "KVM_SET_CPUID2 can >>>> only be called prior to KVM_RUN"). >>> >>> It would certainly make it easier to reason about potential security issues. >>> >> I vote too for this. > > Alternatively, what about adding KVM_VCPU_RESET to let userspace explicitly > pull RESET#, and defining that ioctl() to freeze the vCPU model? I.e. after > userspace resets the vCPU, KVM_SET_CPUID (and any other relevant ioctls() is > disallowed. > > Lack of proper RESET emulation is annoying, e.g. userspace has to manually stuff > EDX after vCPU creation to get the right value at RESET. A dedicated ioctl() > would kill two birds with one stone, without having to add yet another "2" > ioctl(). That has a disadvantage of opting into the more secure behavior, but we can do both (forbidding KVM_SET_CPUID2 after both KVM_RUN and KVM_RESET). Paolo