From patchwork Thu Jul 15 10:39:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Like Xu X-Patchwork-Id: 12380017 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=-13.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 CBDDCC07E96 for ; Thu, 15 Jul 2021 13:21:35 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7EC36613C3 for ; Thu, 15 Jul 2021 13:21:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7EC36613C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m41J0-0003ts-LQ for qemu-devel@archiver.kernel.org; Thu, 15 Jul 2021 09:21:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3ymc-0001Et-9E for qemu-devel@nongnu.org; Thu, 15 Jul 2021 06:39:58 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]:44007) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3yma-0002KE-Mg for qemu-devel@nongnu.org; Thu, 15 Jul 2021 06:39:57 -0400 Received: by mail-pg1-x532.google.com with SMTP id y4so5707242pgl.10 for ; Thu, 15 Jul 2021 03:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1rsa/Sc8Rl//xbiORFj+KjXsMrXTtZFWkAbleB9LyOM=; b=QZ0t15fhgX2AIiPbVTzjb3ROJP5Gi7ZYX/HPjhooo4pekuVpJRFmB55O/yMPavcoDI PiabT2Gc91TQe4FUTJ1qj2i3jNidFD5dXCCQsNDJoq1lDGynx8oSQJd+eEVyOPBEzYXL aQuoSkRXOElDvCgkZA9QzdcGayFF6WyQiBDRdMv26bFsLmJy5mQenLGPQG0BlJX6VXhR /0r6wcIXcrAnmVkbBXulLuaZ2pSopu3so0kpJULJ2652KDofcfvEOLwTDkWuhfg8b5aI dsV8rLWMZosHRYKK74ku3PAGVIt5PZR+lLAi+zLQeM1+YIMj9lQIPnvLYB77im1VyHF+ otlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=1rsa/Sc8Rl//xbiORFj+KjXsMrXTtZFWkAbleB9LyOM=; b=bQXuq7zaLMGuG7UzwhWQxIqldAPCIVYPfwBezioHSdygp5oSIRqJ5snM/kIzpUpVnZ dWbxfCNJYK1VndOTH+Ljtt/MHRtGxbmdZeZVaWC8y+nb3M8Z0V/qqkv6ugvxMK6UVMps o02o7P9ngK8mG7MtAVT7NLrscBoJlQ06SMVg2JV8zV3tYxcDCk83ZYg48t+Z6VaTPkKt BdVu5W0O9Gn1aKvTcC5ipLnWAdqQUlA9qE3cxlU4e6QppbkMzwdElwIWU2XuSg4RhJHU P1GI8lhcA29CR2P2lV7Sh7+fVFRXMGZRqyq647r38uvBBxEKhX25OUOxrUQcbRw4H+7J 4A0g== X-Gm-Message-State: AOAM531r8bGK/7SBBDAv9kZgKLpCI2trkZQWV0V8mnMbjSEfMLnWUztV g5Kkv7vumFDOsvNzOqMlvMo= X-Google-Smtp-Source: ABdhPJxd3BPPSR/9X91SMlDMlliFMLHhQgRPOjwX/K01MYcK7gsgS3Ca05UODxQyOIcHZSTKJxwe8A== X-Received: by 2002:a63:ff4f:: with SMTP id s15mr3949949pgk.193.1626345594682; Thu, 15 Jul 2021 03:39:54 -0700 (PDT) Received: from localhost.localdomain ([103.7.29.32]) by smtp.gmail.com with ESMTPSA id lt15sm8820982pjb.1.2021.07.15.03.39.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Jul 2021 03:39:54 -0700 (PDT) From: Like Xu X-Google-Original-From: Like Xu To: Eduardo Habkost , Joerg Roedel Subject: [PATCH] target/i386/cpu: Use the KVM reported value for the number of ASIDs Date: Thu, 15 Jul 2021 18:39:45 +0800 Message-Id: <20210715103945.95004-1-likexu@tencent.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::532; envelope-from=like.xu.linux@gmail.com; helo=mail-pg1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 15 Jul 2021 09:18:44 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Vitaly Kuznetsov , Richard Henderson , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Like Xu If KVM is enabled, use the supported number of address space identifiers (ASIDs) by the CPUID Fn8000_000A_EBX instead of hard-coding it to 0x10. Signed-off-by: Like Xu --- target/i386/cpu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 48b55ebd0a..959c4425a4 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5523,7 +5523,13 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, case 0x8000000A: if (env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_SVM) { *eax = 0x00000001; /* SVM Revision */ - *ebx = 0x00000010; /* nr of ASIDs */ + /* nr of ASIDs */ + if (kvm_enabled()) { + *ebx = kvm_arch_get_supported_cpuid(cs->kvm_state, + 0x8000000A, 0, R_EBX); + } else { + *ebx = 0x00000010; + } *ecx = 0; *edx = env->features[FEAT_SVM]; /* optional features */ } else {