From patchwork Wed Feb 1 13:29:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emanuele Giuseppe Esposito X-Patchwork-Id: 4813 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp279498wrn; Wed, 1 Feb 2023 05:33:04 -0800 (PST) X-Google-Smtp-Source: AK7set8jse8QbEWzp7lq/uhnUY23OOJ6Pye5VUkUDRXynzsk49sItmeq2VI2XaNYqDTBkVdQS9wa X-Received: by 2002:a05:6a20:1588:b0:b8:a0e1:2739 with SMTP id h8-20020a056a20158800b000b8a0e12739mr2988080pzj.3.1675258384058; Wed, 01 Feb 2023 05:33:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675258384; cv=none; d=google.com; s=arc-20160816; b=jBnsTCohLa8C5AsXV2hdvh98/r1rEmbzjrEQ4BhcGSkojXRea4W79UOTf2U/6htn0t C6wbhAeO+JSWgOuXY8AxVkQ+v1TW1qHV1WyB8a2W9vqiTHdGZngvUqq2zCHiwSw6i1iZ 9tndS1jzZZpfs1u30F8td2cl9m9wj37+HtxkqJ8CH1dnDvKJ15Km5Y5aV8YQzOQ1xC8p vOfjYKW8eRR7DS7xK/KX6cjjMU55HFULODahTSpXlIcv9c00HvaZ4MCcx60CUOQBrQFH MgqsNbFc49y6vmarHCIjeOZlz+MGWWTCzKGtFO7pWnVEpWou9ewevs2077W5d5KZKM4u BsSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=WVZhHFqxaYwFzMBunRS7wzwewBfk2ypSvewsEHL38n4=; b=BCtaZ422sYSZY93OlcPa5lofiPCO6rK6EFtg3olhiaEYHpgDk37AQsAwVNt923iiND 5TZXdmTeGmpqm7PcA2zRl/a8dlFPSoCtnzimL8btaw3mgxgR2j/sgFJCPGdi/zgonNWY l7JRiRZyV2d1xFT+Yr1CH8qYjsfzJfAXdWDtx9hsptuM8eQQ84QEyQXkdHnvZgMxXYKs N8WSd8rM7LtD0I5gZ9dpKauK2MCC86UQ5UUhw42KPi/nYWhKYZFdGHAtOM1YXTM1KFXE 8JpTpkFZIKrNpee/86ATpcWHfbAaUfnHadc7zf6DkF+TLFwP7pB/tbGUNCHC3KFWY+vN jPrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=igAwD+qt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n11-20020a170902e54b00b00188a7401d89si22579856plf.481.2023.02.01.05.32.51; Wed, 01 Feb 2023 05:33:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=igAwD+qt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232266AbjBANaP (ORCPT + 99 others); Wed, 1 Feb 2023 08:30:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232243AbjBANaB (ORCPT ); Wed, 1 Feb 2023 08:30:01 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDCD2410A7 for ; Wed, 1 Feb 2023 05:29:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675258153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=WVZhHFqxaYwFzMBunRS7wzwewBfk2ypSvewsEHL38n4=; b=igAwD+qthj1dWAu4O/MH2pQIfecHHJhPAcuG1VQwBYRYf/MSab/xSJDqu1cnwjEcBYSLbY k7V7lkHf12bXLJzTFtbflx7oO2YNS5CuIzzNBRhjayZdks1wGos4BkcxUT+GqZvW5OqChU N4Kej7zFUusuv4/WSS5iQM5HVJ/hvQM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-556--jTa2-zGPn6Z9Z_7KBKPyw-1; Wed, 01 Feb 2023 08:29:09 -0500 X-MC-Unique: -jTa2-zGPn6Z9Z_7KBKPyw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CFBFA8027FD; Wed, 1 Feb 2023 13:29:08 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1666140C2064; Wed, 1 Feb 2023 13:29:08 +0000 (UTC) From: Emanuele Giuseppe Esposito To: kvm@vger.kernel.org Cc: Jim Mattson , Ben Serebrin , Peter Shier , Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , Maxim Levitsky , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org, Emanuele Giuseppe Esposito Subject: [PATCH 0/3] KVM: support the cpu feature FLUSH_L1D Date: Wed, 1 Feb 2023 08:29:02 -0500 Message-Id: <20230201132905.549148-1-eesposit@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756635735134217578?= X-GMAIL-MSGID: =?utf-8?q?1756635735134217578?= As the title suggest, if the host cpu supports flush_l1d flag and QEMU/userspace wants to boot a VM with the same flag (or emulate same host features), KVM should be able to do so. Patch 3 is the main fix, because if flush_l1d is not advertised by KVM, a linux VM will erroneously mark /sys/devices/system/cpu/vulnerabilities/mmio_stale_data as vulnerable, even though it isn't since the host has the feature and takes care of this. Not sure what would happen in the nested case though. Patch 1 and 2 are just taken and refactored from Jim Mattison's serie that it seems was lost a while ago: https://patchwork.kernel.org/project/kvm/patch/20180814173049.21756-1-jmattson@google.com/ I thought it was worth re-posting them. Thank you, Emanuele Emanuele Giuseppe Esposito (3): kvm: vmx: Add IA32_FLUSH_CMD guest support kvm: svm: Add IA32_FLUSH_CMD guest support kvm: x86: Advertise FLUSH_L1D to user space arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/svm/svm.c | 44 ++++++++++++++++-------- arch/x86/kvm/vmx/nested.c | 3 ++ arch/x86/kvm/vmx/vmx.c | 70 +++++++++++++++++++++++++-------------- 4 files changed, 80 insertions(+), 39 deletions(-)