Received: by 10.223.176.5 with SMTP id f5csp727079wra; Fri, 9 Feb 2018 06:18:15 -0800 (PST) X-Google-Smtp-Source: AH8x226xFcS+mBhjDT3cdbSwViDPr8yQPSdDl9WezCCklHogbRmO3/YCVRQxeUhf9iDyXuHy69Nh X-Received: by 2002:a17:902:930a:: with SMTP id bc10-v6mr2754759plb.19.1518185895210; Fri, 09 Feb 2018 06:18:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518185895; cv=none; d=google.com; s=arc-20160816; b=cTPM4IBrU6A4xDs6pT6DO0UEca2kEjmk343WPKNk3Gm9dN3k8+cvgQdY+E7OBL2X03 IVu/CBTgIwnig87oiIw2m/BUhj5d376Zcpi3AZ3rfKOxA49boZnHmn33GaDJ0Ela42W1 0d1WXvTUt/wRWwqYKfRvI5ZIs540EQqSAW9oz3owceVV9oUJwFNOroQ+CA6he/vh3bNI FSHlhYK0D7nF64yzwT+F9ZmFQOiE2TDc5hHaOtylubhPim/1+neMxXaCJ1dGacjiUDvR o9LJPRWqX2uXXibC5X5LxlW8XwcNEx2b823bvuKJ8NJ3q9ragXsNVFuxj+aj2R1LVHyZ MlWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=CAWjNQ1F2Jxxw6SnDn44oO9CTCLK5Mmo+aQYZMTZ/s4=; b=PTJzuWJSAd+DV1ISldHJsaLSUrqFqKeMTC41o4vVXsi0gBVgaa24GyjRGip0ujlhxb Q2rZHSH4JY3GHnSoJvMrtfgxSa3oRIdLLIRfA8yBZ0+m/a7Sg9DANUHB0BEnZ4VO/+pv Wh5bEXYPFt9YDJfElfUp6vZ2lIn2V5bsSjul6omb04QOsQCRb4pV7tFueYfE1WYF4T+L rraT0gfU3g9/dD8pqqAkuNhjcsDZ/n6IN//CU9pwbJ1bXL3iYZRJR39UoR476qbteUZP b3wvuRKzoVL3BLL4FGBi3fdpDz1wVlrrUwAqvd09r0JNV57glWrik0QE3HNr60A4PsbY mLdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jx6oLcE8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h15-v6si1657244pli.212.2018.02.09.06.18.01; Fri, 09 Feb 2018 06:18:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jx6oLcE8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752792AbeBIOQl (ORCPT + 99 others); Fri, 9 Feb 2018 09:16:41 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:38655 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752696AbeBIOQ2 (ORCPT ); Fri, 9 Feb 2018 09:16:28 -0500 Received: by mail-it0-f67.google.com with SMTP id k6so10803973ita.3; Fri, 09 Feb 2018 06:16:28 -0800 (PST) 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=CAWjNQ1F2Jxxw6SnDn44oO9CTCLK5Mmo+aQYZMTZ/s4=; b=jx6oLcE8y6SccmaAveCiB2D2LTJKsuV2rTuYJ7bXQrRbkpnTRHjpmrxoqIxAhMzypC dua/Um8A9u6rncTwEKkkgZudxkeW27GHTs3Nql7mLtYsbZjCQhm20edK2WFflwmuOLUA lgZUwawpQ8AGIxjbgehC9yRyEiyRQqh2PVkG1xlvt8YsG8aUAATBAuXjGHCqn7WiTQnV 8yMZjm2HzHulq+GDl6lvs4Cw8m7n2BF15xPK/EGfQH92qvmoBjfnecu7yzAJZLem+UMV d7OsH5kvbUN3oCtj6uCry3aafp+lZYtF+zd3JfaYfI73TdVkHDxlo6S2iqL58QgfT2pS IPqg== 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=CAWjNQ1F2Jxxw6SnDn44oO9CTCLK5Mmo+aQYZMTZ/s4=; b=n1AAsjCCZKkIE3B/ImwQlI8iP+UQAO8lKphdfCcVTKMHL7B3G/+jwdMcJ7HqYxcx0a 6IYmHc2G7JShLiLGlcoi0+b/XTDr/Z9Rhq734XJrKimpNf6TizPiwrJYwIIoOVZGAp2H D8cptCvG72f4ZEHjhj9T+xBp3AWsYWoMlG2Bb2TpuPVxLCBPiB2RNNsr2gUBMnegxNCJ P+qvMR9OJuNZUUyGsRZ2YATkner+UZtaMTBO7KuLLgRZDSNgHAKxza2hfMnm1FxBC/Um e7A5WW7tb/noNZRM403b0JEay79igVBZHXmi9its0sSu1qUfLXRCu7wkAzPw46R8xT05 eHzA== X-Gm-Message-State: APf1xPB3tMV2ZKN0WfIHjZTRs0Nk9tdzYGkR/vklhMxTddiuX2m+4alY GvlSnvC/BxOj+EsB7JnXo3pSnA== X-Received: by 10.36.57.197 with SMTP id l188mr3751613ita.25.1518185787632; Fri, 09 Feb 2018 06:16:27 -0800 (PST) Received: from localhost.localdomain ([45.248.77.205]) by smtp.googlemail.com with ESMTPSA id m14sm3289136iti.3.2018.02.09.06.16.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Feb 2018 06:16:27 -0800 (PST) From: Wanpeng Li X-Google-Original-From: Wanpeng Li To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Peter Zijlstra , Eduardo Habkost Subject: [PATCH v2] target-i386: add KVM_HINTS_DEDICATED performance hint Date: Fri, 9 Feb 2018 06:15:25 -0800 Message-Id: <1518185725-69559-1-git-send-email-wanpengli@tencent.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wanpeng Li Add KVM_HINTS_DEDICATED performance hint, guest checks this feature bit to determine if they run on dedicated vCPUs, allowing optimizations such as usage of qspinlocks. Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Eduardo Habkost Signed-off-by: Wanpeng Li --- v1 -> v2: * add a new feature word target/i386/cpu.c | 14 ++++++++++++++ target/i386/cpu.h | 3 +++ target/i386/kvm.c | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index d70954b..e2974ad 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -358,6 +358,20 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS] = { .cpuid_eax = KVM_CPUID_FEATURES, .cpuid_reg = R_EAX, .tcg_features = TCG_KVM_FEATURES, }, + [FEAT_KVM_HINTS] = { + .feat_names = { + "hint-dedicated", NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, + }, + .cpuid_eax = KVM_CPUID_FEATURES, .cpuid_reg = R_EDX, + .tcg_features = TCG_KVM_FEATURES, + }, [FEAT_HYPERV_EAX] = { .feat_names = { NULL /* hv_msr_vp_runtime_access */, NULL /* hv_msr_time_refcount_access */, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index f91e37d..9f73692 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -475,6 +475,7 @@ typedef enum FeatureWord { FEAT_8000_0008_EBX, /* CPUID[8000_0008].EBX */ FEAT_C000_0001_EDX, /* CPUID[C000_0001].EDX */ FEAT_KVM, /* CPUID[4000_0001].EAX (KVM_CPUID_FEATURES) */ + FEAT_KVM_HINTS, /* CPUID[4000_0001].EDX */ FEAT_HYPERV_EAX, /* CPUID[4000_0003].EAX */ FEAT_HYPERV_EBX, /* CPUID[4000_0003].EBX */ FEAT_HYPERV_EDX, /* CPUID[4000_0003].EDX */ @@ -670,6 +671,8 @@ typedef uint32_t FeatureWordArray[FEATURE_WORDS]; #define CPUID_7_0_EDX_AVX512_4FMAPS (1U << 3) /* AVX512 Multiply Accumulation Single Precision */ #define CPUID_7_0_EDX_SPEC_CTRL (1U << 26) /* Speculation Control */ +#define KVM_HINTS_DEDICATED (1U << 0) + #define CPUID_8000_0008_EBX_IBPB (1U << 12) /* Indirect Branch Prediction Barrier */ #define CPUID_XSAVE_XSAVEOPT (1U << 0) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index ad4b159..44ee524 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -383,6 +383,9 @@ uint32_t kvm_arch_get_supported_cpuid(KVMState *s, uint32_t function, if (!kvm_irqchip_in_kernel()) { ret &= ~(1U << KVM_FEATURE_PV_UNHALT); } + } else if (function == KVM_CPUID_FEATURES && reg == R_EDX) { + ret |= KVM_HINTS_DEDICATED; + found = 1; } /* fallback for older kernels */ @@ -801,6 +804,7 @@ int kvm_arch_init_vcpu(CPUState *cs) c = &cpuid_data.entries[cpuid_i++]; c->function = KVM_CPUID_FEATURES | kvm_base; c->eax = env->features[FEAT_KVM]; + c->edx = env->features[FEAT_KVM_HINTS]; } cpu_x86_cpuid(env, 0, 0, &limit, &unused, &unused, &unused); -- 2.7.4