From patchwork Mon Nov 14 18:14:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Mattson X-Patchwork-Id: 9428161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 059E0602F0 for ; Mon, 14 Nov 2016 18:22:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDFCD28AB4 for ; Mon, 14 Nov 2016 18:22:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E0F5528AB9; Mon, 14 Nov 2016 18:22:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76A3128AB4 for ; Mon, 14 Nov 2016 18:22:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935567AbcKNSWn (ORCPT ); Mon, 14 Nov 2016 13:22:43 -0500 Received: from mail-pg0-f48.google.com ([74.125.83.48]:36863 "EHLO mail-pg0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932174AbcKNSWl (ORCPT ); Mon, 14 Nov 2016 13:22:41 -0500 X-Greylist: delayed 485 seconds by postgrey-1.27 at vger.kernel.org; Mon, 14 Nov 2016 13:22:41 EST Received: by mail-pg0-f48.google.com with SMTP id f188so56551742pgc.3 for ; Mon, 14 Nov 2016 10:22:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VA5ySJUzEekLIcsWGwlJ6sggJQgLuMW6gp4F5HvFSE0=; b=ZLJOOwByUkKEGcf3VgYxHMZpzmQ3uyIriS/3bcGYD9LpDpdMcj0kaih2uwrzdJg9RF BzzyuAOpbEjoQQ6MngKgHENyqYlvcR1bHN4HRGQG8hqecaKcx3MGNe+BpWSHSvSi1JLo OVw7TPg41t6O63DiFyZTlfDIeqQC6F6uUzMpnm47tixbG0Id+6qyDaG+9YeveCs9MhmA +3DonjQqf9nGjeI1XJBiP2ce2ZjAG+bs2YpKFyqWMY0T+GVeqRV1hLIz1707LGaL0qrx dTvAbpm0Hm6bK4N/C3ae4sGQRL4LpcHqskd/BQ5KWvPuw9tXg+Ah4UZYbsGLklAUQz4D yHUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VA5ySJUzEekLIcsWGwlJ6sggJQgLuMW6gp4F5HvFSE0=; b=V2tyMIrRScDrrOA1wbhBxMk/5Xw+CEQLDbxJ8TAtKR/36uzNLLaxzhHBIxO2tfnOAI NjJFAG1SWRYb/aqTRC5rz4ssbZQGA5dLzHHUs9YYXBoQJCzVwmW/qRtaEzIm4tI/Ux9u XtIZzU5IjcUuACdrNfqUIYqiDYzZWQ1o6YNdk21Da/RptSc6uMifJX1pyNQsNnLGTJl8 2JiM3STtufEehiAXalzHDhgzRJA5YF78AO8Xj/nF7TmQk/eJA9eaA+oCFWlcYSrKbOTw LUIVKBjv93HW+LYTu+LgseAO1rTj9cew3VRlOiyvKtgVlP9uUYo5PIyqE/0M4VSJr85n MPkw== X-Gm-Message-State: ABUngveKsRgZ3t7RnFHNgfrX5i5URNR38hw9QQbliQ5yVfxH5wywmJ9Rk+hcreFBHi0VtEQc X-Received: by 10.99.94.196 with SMTP id s187mr70901431pgb.107.1479147276053; Mon, 14 Nov 2016 10:14:36 -0800 (PST) Received: from jmattson.sea.corp.google.com ([100.100.206.154]) by smtp.gmail.com with ESMTPSA id w85sm36810678pfk.57.2016.11.14.10.14.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Nov 2016 10:14:35 -0800 (PST) From: Jim Mattson To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , kvm@vger.kernel.org Cc: Jim Mattson Subject: [kvm-unit-tests PATCH] x86: Test disabled local APIC Date: Mon, 14 Nov 2016 10:14:03 -0800 Message-Id: <1479147243-26864-1-git-send-email-jmattson@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: References: Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This test disables and re-enables the local APIC and ensures that CPUID.1H:EDX.APIC[bit 9] mirrors IA32_APIC_BASE[11]. Signed-off-by: Jim Mattson --- x86/apic.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/x86/apic.c b/x86/apic.c index eff9a11..39c7fd1 100644 --- a/x86/apic.c +++ b/x86/apic.c @@ -104,6 +104,28 @@ void test_enable_x2apic(void) } } +static void test_apic_disable(void) +{ + u64 orig_apicbase = rdmsr(MSR_IA32_APICBASE); + + report_prefix_push("apic_disable"); + + report("Local apic enabled", orig_apicbase & APIC_EN); + report("CPUID.1H:EDX.APIC[bit 9] is set", cpuid(1).d & (1 << 9)); + + wrmsr(MSR_IA32_APICBASE, orig_apicbase & ~(APIC_EN | APIC_EXTD)); + report("Local apic disabled", !(rdmsr(MSR_IA32_APICBASE) & APIC_EN)); + report("CPUID.1H:EDX.APIC[bit 9] is clear", !(cpuid(1).d & (1 << 9))); + + wrmsr(MSR_IA32_APICBASE, orig_apicbase & ~APIC_EXTD); + wrmsr(MSR_IA32_APICBASE, orig_apicbase); + apic_write(APIC_SPIV, 0x1ff); + report("Local apic enabled", rdmsr(MSR_IA32_APICBASE) & APIC_EN); + report("CPUID.1H:EDX.APIC[bit 9] is set", cpuid(1).d & (1 << 9)); + + report_prefix_pop(); +} + #define ALTERNATE_APIC_BASE 0x42000000 static void test_apicbase(void) @@ -398,6 +420,7 @@ int main() mask_pic_interrupts(); test_apic_id(); + test_apic_disable(); test_enable_x2apic(); test_apicbase();