Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1661190pxj; Wed, 19 May 2021 10:53:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyun6B7kJRcjFRutECQWxxGZlUjhtf5kxVcvdjaIEASwZ7lAYZGYaae0Cj2z+3IqEmQTOHK X-Received: by 2002:a05:6602:2cd5:: with SMTP id j21mr719136iow.83.1621446783031; Wed, 19 May 2021 10:53:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621446783; cv=none; d=google.com; s=arc-20160816; b=SahqSJ/Aa4vdNIHLSI9XXDdlIPvC9QYjxUecZ5FMZFa3x1jtZ5gXtszRICJ8tP5EAq 61aG88bNfPtfdAjgmVz0X2Fr3XIDVj6MPBIvVvNHmv/tWly4/JuxSeKR8b5hO5sbIJjg QtmtASsGeQPVvb+CIdENrW9HBkJd/Xz7aFnBWpB0Q8rb0Ef0vWngRP4yAzhHvSJqj1EB pqkDDTwULxszaZml+ZGWQE9w/nu4GF7IWxn+CXaSlmw7NI1oXNCIPJWLmmBlwS892RsF zbHd1W4334yHgNCri8OU1wRDWwNa5xMGv/NsaeTD5jcWPlzl11p48QcHAZXboQTkD+aN z09g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=hMetlmNBWaKkSQsHWQlPS1UZ381FEjltyXsY7/tZa1o=; b=kCmxQT+LJQOmY83alMhaWb/XnwsUNzyb1jz3AtfEP2sMsRVVspWABxAB3Mfw5fVSX2 0T3kRXKyxEgnbg5697oRrX+IfwKcWEwIHqodaUTBiadGlbWbLpcglZqeHvEcKMNa1mH7 hrpvql9p4n2vNP9YMLM7g/vcagtcf0zBuK0T576Pz09pcIyohZH13Ls1WHp+h9Kqx/Vg eYMcH8vizEaTCistW3vcG6k4tIjckw7xUnAMbUv4W02hcxqjmhIuVzfZtayu7Nk9R4Hx rk4gGdPm4TTisGdqExwl9dgbN7QY7vrtij4He0Cm/RkPtk6Q9RgR29xla6rWsu6v9874 kWXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UuEAQokT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k2si25003988iow.30.2021.05.19.10.52.47; Wed, 19 May 2021 10:53:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=UuEAQokT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348686AbhERLBL (ORCPT + 99 others); Tue, 18 May 2021 07:01:11 -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-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