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 2EC6BC433ED 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 EC38B6008E for ; Tue, 18 May 2021 10:59:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348685AbhERLBL (ORCPT ); Tue, 18 May 2021 07:01:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:40059 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243635AbhERLBK (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-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-154-Gs0cPdfNPDmaxdAy1aVbqg-1; Tue, 18 May 2021 06:59:49 -0400 X-MC-Unique: Gs0cPdfNPDmaxdAy1aVbqg-1 Received: by mail-wr1-f72.google.com with SMTP id p11-20020adfc38b0000b0290111f48b8adfso1938508wrf.7 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=d4BnC/A8d9zTI8RQ/lDM8P+4yiHXifHxmVdeHf9FLu/x6V2nISPRaJD3v3yZZA+EQk gHlY7aOjm+PM/ftaUEFuOZVi3KZCa/0r235Z4wum8FUIT9/Fg51sZ41uTioel+dryoJ4 YoSqXvoSKmbPhSVUulL2v5Ahk2ch4RSsTf7EtUMktJPPWK/0P2fcFAG0Iep6GZkX2Ul7 4jDf66BfHc8/Ls1TWj6Ox3wj/ZPerIOqDgoKINxJH0gGdmZbXfr3zu7M3JY49fgmDT98 C+t5/jKbx291joLjgR3FKZab06r52dsE2w/t9aSQK73MQJciBKjBJgJKgEloQbb5JAPl 0GyA== X-Gm-Message-State: AOAM530PT7EFR0sZ6NYbBwnMIoEeI+d/04CfzPbnZWBjNOXuGxn8ZfCd aY6cuflNqGfyY5QTs5rFU5vPwlPPiXVR+kKv87rdY6IKGaKUwbq+XExdOq0fDcFy6TfLICC6JiD yFBYF2VzFyuuI X-Received: by 2002:a1c:a7c2:: with SMTP id q185mr4773576wme.112.1621335588449; 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: kvm@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