Received: by 10.223.185.116 with SMTP id b49csp8830338wrg; Fri, 2 Mar 2018 08:39:37 -0800 (PST) X-Google-Smtp-Source: AG47ELvZxiOH948tYsJUYM5KG1V/gv6mzgOH2y+Esig1Tu27blHh41ANpjy3xOlzOVl3HiF4EIKc X-Received: by 2002:a17:902:518d:: with SMTP id y13-v6mr5832228plh.121.1520008776952; Fri, 02 Mar 2018 08:39:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520008776; cv=none; d=google.com; s=arc-20160816; b=lWEQeW0fIfEsCuVaPCnE7TakGInnSUDDA+dk4Pkhod5I0ggj9EzUIStsHlV4kk95WA viLykMuueiPB48M9tcVK3qz71WAJM90jr6NUMLMKt25vNS8syAd2Gr7vz2BOTbKrWjUh jVJD6lzJbZtpdAwpuK2s0up8nt2ibts/ZIq+3niaCquDpctlbRUFKf+S831rpt2BNRCL KC8wfN0ZTMBFVfa178i7s4v3Vkp2NNZ2T87h6nr/SOzt+dwIVb6RpTZ5NOlScBdz7g+s 3yM9OlS6DwKUdOiPrcQ4JIO3BJQGdByx1UJexaF/vTzX70MXZ16vrF29+APVdYsLifbc NIxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:arc-authentication-results; bh=8fuSzMvx5tmfk1bhWU4/f7/GIh/zUK8x5+A3TuUaN9s=; b=nneWMMfnU/0RBgW3xyPJTTkzLC3kf8MJFpfVOKU2E5eXRKDe3IZkHWpUWLgEMPI3Ht 1aNJdaFmqezLoIGftIl8StsvaX45tZlt/SJtzh3hXNKWUeckbz00xvcQCyVYuE0N38xI IpeZ8IAqK97QuCE2bp3fX9jwAfSaW1KmoPL2sjWoUp5yzNUWRiFheKwspuanMWwWM+Ey 52VtEX7I8tJlUFXSKK3I6RsOAmefWRzdZSPK2eLepzTSoPxRkr7h5wj7ZFb6a8XaB+br EL7k1TQNE/c1Xjfn43t64X/QMzh7HPkd4evs05+TsQhDNX+bn+R1ZLqEyXo4fQP+WppD bomA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=O+fpVDi/; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2-v6si5010414pll.93.2018.03.02.08.39.22; Fri, 02 Mar 2018 08:39:36 -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=@amdcloud.onmicrosoft.com header.s=selector1-amd-com header.b=O+fpVDi/; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936454AbeCBQTY (ORCPT + 99 others); Fri, 2 Mar 2018 11:19:24 -0500 Received: from mail-by2nam01on0044.outbound.protection.outlook.com ([104.47.34.44]:42045 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S935554AbeCBQR7 (ORCPT ); Fri, 2 Mar 2018 11:17:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector1-amd-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=8fuSzMvx5tmfk1bhWU4/f7/GIh/zUK8x5+A3TuUaN9s=; b=O+fpVDi/QKbyJL//FNTvinP3ohqP8QeWJ9MxUQmCgijUU/QhqX6YDV2l7qRPo4FnqW6zaDToxNmALmSwu4hk0dTFsuMOn/XJBI+6dqYgwWXhxQNaSr4v1oHJlsEUfU8QMPuqzXFu/08f/pTlR/2WV/SY+G4OCPK3kTPJomdpP/c= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Babu.Moger@amd.com; Received: from linux-pyp0.amd.com (165.204.77.1) by BN6PR12MB1761.namprd12.prod.outlook.com (10.175.101.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.548.13; Fri, 2 Mar 2018 16:17:56 +0000 From: Babu Moger To: joro@8bytes.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, x86@kernel.org Cc: babu.moger@amd.com, pbonzini@redhat.com, rkrcmar@redhat.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC 1/3] arch/x86/kvm: SVM: Introduce pause filter threshold Date: Fri, 2 Mar 2018 11:17:34 -0500 Message-Id: <1520007456-85293-2-git-send-email-babu.moger@amd.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1520007456-85293-1-git-send-email-babu.moger@amd.com> References: <1520007456-85293-1-git-send-email-babu.moger@amd.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: BN6PR14CA0041.namprd14.prod.outlook.com (10.171.172.155) To BN6PR12MB1761.namprd12.prod.outlook.com (10.175.101.22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c5c75642-f93f-4bf6-db71-08d5805928c9 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020);SRVR:BN6PR12MB1761; X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1761;3:HJ0+YFWVvh/f8UogAQvKwzmwdWCDe6mpBhaoM2SO6DlZAQvBU7HxibcNX6e1Yjkg6fvcu/qgCqFhbG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/EehF7PV9OAgBaz+wPntMAucEJ0Unl7fMgPxZwYCBKFGdvM/XMr3fpY5/ig5blMN5IcFygPb+J/cVKMoxlZRfBUkNFcoFtFFZu6MyyKRhj6m8QWkTF0Vgl9D6/Cp4x20wJwKNFrj3oeyLSxkX8HOUHIwFCtGKQS9tJ5VA6SiQIdjphFj4mP7m8/pCveGefC6LUsSKnNXuBiUjnKS+CRLBaUWnVpSOtPfNUQ3kxNKGraybsVsyJrNqk2f3KDSL2JQ197QAs;4:jvi5Zo3emdwxHXw4/oJdyEkUhZQn1FArIYxVFbhMmB/zGOLEq+g0OB1BWYReqb28Se9oc8jd6G0+Iy+yI47viQZRJ5H3vapOQXsfT0KoAkFZMHIAumO1C/VA8eYKQL9tL83LzZRvIrAfT6uCi0VajNS5gzdI7/p/J74E9dX1Jt/Zm7oKhi5VAj0AWgFhPvSHVVlYEG0B0ClP9q67eq+JLpg73rv12dvR8aOC3tNQAHFeAQ3a7xapdTICNLj2/5ETV0meLyVkr0TJIfd57psBc5GAVPTw4lmXFhz/sNu8owgGeMNdk2lgax7y9IB/z5Vy X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(767451399110); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040501)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231220)(944501161)(10201501046)(6055026)(6041288)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(6072148)(201708071742011);SRVR:BN6PR12MB1761;BCL:0;PCL:0;RULEID:;SRVR:BN6PR12MB1761; X-Forefront-PRVS: 05991796DF X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(376002)(396003)(39380400002)(39860400002)(366004)(346002)(199004)(189003)(51416003)(2950100002)(386003)(53936002)(186003)(26005)(7696005)(6486002)(52116002)(16526019)(68736007)(6666003)(4720700003)(76176011)(106356001)(16586007)(59450400001)(316002)(8936002)(50226002)(4326008)(5660300001)(36756003)(81166006)(86362001)(48376002)(50466002)(575784001)(81156014)(2906002)(7736002)(3846002)(66066001)(105586002)(305945005)(8676002)(53416004)(47776003)(97736004)(6116002)(478600001)(72206003)(25786009);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR12MB1761;H:linux-pyp0.amd.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN6PR12MB1761;23:+VHJEGDn1u79f4hqbB7Dh0yni237kOS4ZRTjON+jT?= =?us-ascii?Q?XwU5oHSB/ZsrVCzDkFYG1oOB84ZvDefQqUtQ2xj9qpD2K/98oKuC1d31p98N?= =?us-ascii?Q?uXnxTzhe7qAY6IBrLtCGO9nkdc1rV1QX3MVf28uv1W3k4IZExGgerZ7F3h8j?= =?us-ascii?Q?CMILHkDwQD1ND2J40nuUDtVSq9FsGE9tgJ0G7Zejv/M1JC7biKOW6RK0YnAX?= =?us-ascii?Q?Z6zn45qOwlWmB8vcHJzzy9acP/l4RPlQQk21l4Zw+gOuP7eWAEsmyYf5/8bM?= =?us-ascii?Q?t7vqf5pFerXbJJzhIzfvPu4v1y+d9w9xTjia/DyTCxkbIjFuPfcrFs38yqPW?= =?us-ascii?Q?3JKILL3oUnBJMhp8CntJ238xephzQ6ENUZPvQMvPwfy+GZDDqyRxh1f1XMUv?= =?us-ascii?Q?psiAshHBGUgQN+UJ2/8XZi0+mEZpEm+ERCHI/wJoyhnFai78NZfmb8wWklXh?= =?us-ascii?Q?kez6oAmL+nIesKqjusrWUMsw/BlwNPU3/z5VvqMP9irmXurcC48lfAWcKQgR?= =?us-ascii?Q?Xg/jhYll7cAvrdkrZuR+ZyxQZ/aj3vcO5T9Bd7+7VLei/a4OTSTvvVKz7dkL?= =?us-ascii?Q?EJWkX2rIfPC5eONoawTyR0EvwmXvwqV6l1wR31xdmiVR2T4V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Mr3tMa7gEGeXzHfuyqrpu2L3YibySbUSkS+iUASZuc6G3i7KaMa6QAs=;5:CbOjxtcuWUq0wrrkiJ++K2i5rbMQYMVrpiQfFAxRgn64uljUxoE5bALqbJBHy0t1ZLar80cu/B7/8g1Pqw0PUvgQB/7zLRGgb9hhKOJTlZ3f/TJrucpq5Cj1mXvi/Pr10twhAjdKLE6uAPPVslEKSEoPUgz3IlXntsWCfGE+APU=;24:sEZN2hN47WOQ3PiAKrLKMMFla/TWxgA6bF+uVuwYVcTHmlq5hpiee/w+Z8I5du/e0DjaUp97XThbYG6m1ptGYNeK+bzNuDj3FoZKJKiZ6EE=;7:61r2TXdYeoJj+mI/ry9bUKo3IE6HboxmD5eRPsa+oLGlbX552jOQ/Fcb7V8Rk1SigG5vF6aNy3oSpKUEWPZSvRfhaQgUhdQ5l0sHgOSIefA8SIni/MQs+MDLgy43oTakG4NV88U7dOEpwNcrZftuOgONll3W+XHJllnR7W9R9rRhRla+FLgDIPvxlDzX8DNFr/dcEgVvEzMohrRZfxGsgNs/QdYW8+AVMax+pOIHArCjaXLAt+L0ro0u4/5PTHaA SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BN6PR12MB1761;20:mko53rOSD1aKWM5jwGwjUwSCpGT3UZyYo6SNZhuTNyUnKN/HyEw1bvBq04G9g7nsswjB76xXvp1AAf3AA/fHfv6RoSMOy0bFIAajRoRFe8XX+/Mequ0/fRziasxuHlY0xknAC3xm/u4RB6hB1JQeI8l3CqHwDfgAOxvIykvUpPfu+oNW8SwaKvPF0kQ3sZzV+wkHoI+/Vpqd0t6qY5UzH2tznR632Ex1klRJvLZ1t8uI95EEds6xQEG/dDCwyUKj X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2018 16:17:56.2391 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5c75642-f93f-4bf6-db71-08d5805928c9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR12MB1761 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds the support for pause filtering threshold. This feature support is indicated by CPUID Fn8000_000A_EDX. See AMD APM Vol 2 Section 15.14.4 Pause Intercept Filtering for more details In this mode, a 16-bit pause filter threshold field is added in VMCB. The threshold value is a cycle count that is used to reset the pause counter. As with simple pause filtering, VMRUN loads the pause count value from VMCB into an internal counter. Then, on each pause instruction the hardware checks the elapsed number of cycles since the most recent pause instruction against the pause Filter Threshold. If the elapsed cycle count is greater than the pause filter threshold, then the internal pause count is reloaded from VMCB and execution continues. If the elapsed cycle count is less than the pause filter threshold, then the internal pause count is decremented. If the count value is less than zero and pause intercept is enabled, a #VMEXIT is triggered. If advanced pause filtering is supported and pause Filter Threshold field is set to zero, the filter will operate in the simpler, count only mode. Signed-off-by: Babu Moger --- arch/x86/include/asm/svm.h | 3 ++- arch/x86/kvm/svm.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/include/asm/svm.h b/arch/x86/include/asm/svm.h index 78dd9df..7a3d9c7 100644 --- a/arch/x86/include/asm/svm.h +++ b/arch/x86/include/asm/svm.h @@ -60,7 +60,8 @@ struct __attribute__ ((__packed__)) vmcb_control_area { u32 intercept_dr; u32 intercept_exceptions; u64 intercept; - u8 reserved_1[42]; + u8 reserved_1[40]; + u16 pause_filter_thresh; u16 pause_filter_count; u64 iopm_base_pa; u64 msrpm_base_pa; diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index f40d0da..50a4e95 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -4175,6 +4175,8 @@ static void dump_vmcb(struct kvm_vcpu *vcpu) pr_err("%-20s%08x\n", "exceptions:", control->intercept_exceptions); pr_err("%-20s%016llx\n", "intercepts:", control->intercept); pr_err("%-20s%d\n", "pause filter count:", control->pause_filter_count); + pr_err("%-20s%d\n", "pause filter threshold:", + control->pause_filter_thresh); pr_err("%-20s%016llx\n", "iopm_base_pa:", control->iopm_base_pa); pr_err("%-20s%016llx\n", "msrpm_base_pa:", control->msrpm_base_pa); pr_err("%-20s%016llx\n", "tsc_offset:", control->tsc_offset); -- 1.8.3.1