From patchwork Sun Apr 30 05:35:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongjiu Geng X-Patchwork-Id: 9706023 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 DDA4C60245 for ; Sun, 30 Apr 2017 05:31:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1A6126E46 for ; Sun, 30 Apr 2017 05:31:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C550827FA8; Sun, 30 Apr 2017 05:31:56 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 615B026E46 for ; Sun, 30 Apr 2017 05:31:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hwf0XANl+329shGBvdLkQLzz0SrVNK688wh/sv6sRkE=; b=kQs0NICYXZVp9T gXbbQ1pV/fPeOD8MOey/uTVUW3nuc3HGDunSDhzWulFtjoEKDbu/6qrf167JxfFNLyAquBN78bVok +dt1887YzVvkJUcD9Rk0MPB9dUpcowv6DCytKffhHZe+XNP5Q9o6nmEDVYODNjmyzRI2QKeEdvg+L iYMub0ic+ghcW9SQVR92L0g6JIxZXdxnsBy8Y18vLVXO1y+bceScUjyJDRcOqiyAbbvKffJdqRGsT acd3y17LfBj9hSA8igA4Fx2qhXcdvkni6N2ArAaWNxwK56AfJ1za192dHeeFehFNhSvowLlV5uT9D J4n1ilpcCcZK7rOkh9Ow==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1d4hSd-0002cF-DF; Sun, 30 Apr 2017 05:31:55 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187] helo=dggrg01-dlp.huawei.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1d4hSZ-0002Zp-CA for linux-arm-kernel@lists.infradead.org; Sun, 30 Apr 2017 05:31:53 +0000 Received: from 172.30.72.55 (EHLO DGGEML404-HUB.china.huawei.com) ([172.30.72.55]) by dggrg01-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id ANP74825; Sun, 30 Apr 2017 13:24:40 +0800 (CST) Received: from linux.huawei.com (10.67.187.203) by DGGEML404-HUB.china.huawei.com (10.3.17.39) with Microsoft SMTP Server id 14.3.301.0; Sun, 30 Apr 2017 13:24:28 +0800 From: Dongjiu Geng To: , , , , , , , , , , , , , , , , , , , Subject: [PATCH v3 2/4] target-arm: kvm64: detect guest RAS EXTENSION feature Date: Sun, 30 Apr 2017 13:35:04 +0800 Message-ID: <1493530506-26833-2-git-send-email-gengdongjiu@huawei.com> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1493530506-26833-1-git-send-email-gengdongjiu@huawei.com> References: <1493530506-26833-1-git-send-email-gengdongjiu@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.187.203] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.5905751B.00D6, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 77361359a30c7c2a8f847e8672266b2b X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170429_223152_480270_945985DA X-CRM114-Status: GOOD ( 10.92 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: songwenjun@huawei.com, wuquanming@huawei.com, xiexiuqi@huawei.com, gengdongjiu@huawei.com, huangshaoyu@huawei.com, wangxiongfeng2@huawei.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP check if kvm supports guest RAS EXTENSION. if so, set corresponding feature bit for vcpu. Signed-off-by: Dongjiu Geng --- linux-headers/asm-arm64/kvm.h | 1 + linux-headers/linux/kvm.h | 1 + target/arm/cpu.h | 3 +++ target/arm/kvm64.c | 8 ++++++++ 4 files changed, 13 insertions(+) diff --git a/linux-headers/asm-arm64/kvm.h b/linux-headers/asm-arm64/kvm.h index 651ec30..acb5c4d 100644 --- a/linux-headers/asm-arm64/kvm.h +++ b/linux-headers/asm-arm64/kvm.h @@ -97,6 +97,7 @@ struct kvm_regs { #define KVM_ARM_VCPU_EL1_32BIT 1 /* CPU running a 32bit VM */ #define KVM_ARM_VCPU_PSCI_0_2 2 /* CPU uses PSCI v0.2 */ #define KVM_ARM_VCPU_PMU_V3 3 /* Support guest PMUv3 */ +#define KVM_ARM_VCPU_RAS_EXTENSION 4 struct kvm_vcpu_init { __u32 target; diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index 4e082a8..e0fa5b8 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -883,6 +883,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_PPC_MMU_RADIX 134 #define KVM_CAP_PPC_MMU_HASH_V3 135 #define KVM_CAP_IMMEDIATE_EXIT 136 +#define KVM_CAP_ARM_RAS_EXTENSION 137 #ifdef KVM_CAP_IRQ_ROUTING diff --git a/target/arm/cpu.h b/target/arm/cpu.h index a8aabce..1cf4a5b 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -610,6 +610,8 @@ struct ARMCPU { /* CPU has memory protection unit */ bool has_mpu; + /* CPU has ras extension unit */ + bool has_ras_extension; /* PMSAv7 MPU number of supported regions */ uint32_t pmsav7_dregion; @@ -1216,6 +1218,7 @@ enum arm_features { ARM_FEATURE_THUMB_DSP, /* DSP insns supported in the Thumb encodings */ ARM_FEATURE_PMU, /* has PMU support */ ARM_FEATURE_VBAR, /* has cp15 VBAR */ + ARM_FEATURE_RAS_EXTENSION, /*has RAS extension support */ }; static inline int arm_feature(CPUARMState *env, int feature) diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 6111109..fd30a5a 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -518,6 +518,14 @@ int kvm_arch_init_vcpu(CPUState *cs) unset_feature(&env->features, ARM_FEATURE_PMU); } + if (kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_RAS_EXTENSION)) { + cpu->has_ras_extension = true; + cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_RAS_EXTENSION; + } else { + cpu->has_ras_extension = false; + unset_feature(&env->features, ARM_FEATURE_RAS_EXTENSION); + } + /* Do KVM_ARM_VCPU_INIT ioctl */ ret = kvm_arm_vcpu_init(cs); if (ret) {