Received: by 10.223.176.5 with SMTP id f5csp947524wra; Fri, 9 Feb 2018 09:47:36 -0800 (PST) X-Google-Smtp-Source: AH8x224pX7TtWFw82YRD4Yeu3wlJ3qI9uphYup2J9JC/hc6IkmPllkFb0ei8HLOdALSqsQgsWKvR X-Received: by 10.98.69.93 with SMTP id s90mr3679641pfa.31.1518198456708; Fri, 09 Feb 2018 09:47:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518198456; cv=none; d=google.com; s=arc-20160816; b=OGR4b4LBF1LdEqM74xpdoyuySfZ8miMUup0tAKDX16rYRhqBu0yWeC+rsKDGPMVukc fdtyns8ogs3Fh2ANhQYWc7ynakPZGisUvrGYn+S/NdxVPQZaiFOqaB3raxOV4R5cAk4g Edk7I5MJAhlVisJpmS48a3g2eZvUzfWYFzIOqigcMp8wi5h4ovRCWBf7oICZFYYjUtZb 5vO6qZfzYuDOVLejZfDNanF+vLhYLXjompQRaU73ToU9fkTOwMtSV1IOsBK693CGVjGB 6V8yIOTL0N0sN0CJXZoi4yNXc4u1BDRm8Rs6vBuOSRXpUfg8VSZoSdCqWngB+QPW/XM4 X0/w== 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:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id:arc-authentication-results; bh=Mf1t0hpN3mP6/cjxXiPmIewHsRu+eloJJqPOPJUte2M=; b=a5Kae1nggD9Ff5B5hMAOE8j2SbhBujO2pOpFcsYSR8Ar3SWM9wCMgwCuvLkbrD5vPI vxR4u7ULFnmE0uX7/hdIsuhC4WuBMRXv58/tWWFrWGvze+95JcPz6x1VdmuQCQTXC3tY DYZ3JKxcCuFAWsOoAPSu2vQam8We5LRyg/bRcrt2SqQUgcZBesf8kyIxPlT5d1sUMK45 gtqtcHj5woRurTg59AghaAjnDhliLBVYz1P84qb2pNTG89GiKWS2w6m5hz5iDlgqjQMl e0k3njiqfrBnaudXsOvXeXUm8GWVu5A6kKpQlIeGKSiKLRME5HOG2P2X8U9eoHqUP7sz 7WjQ== ARC-Authentication-Results: i=1; mx.google.com; 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 b5-v6si1807452pli.695.2018.02.09.09.47.22; Fri, 09 Feb 2018 09:47: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; 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 S1751333AbeBIRqp (ORCPT + 99 others); Fri, 9 Feb 2018 12:46:45 -0500 Received: from foss.arm.com ([217.140.101.70]:49916 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751028AbeBIRqn (ORCPT ); Fri, 9 Feb 2018 12:46:43 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D11091529; Fri, 9 Feb 2018 09:46:42 -0800 (PST) Received: from [10.1.207.55] (melchizedek.cambridge.arm.com [10.1.207.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E2A4A3F25C; Fri, 9 Feb 2018 09:46:39 -0800 (PST) Message-ID: <5A7DDDEE.9050306@arm.com> Date: Fri, 09 Feb 2018 17:44:14 +0000 From: James Morse User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.6.0 MIME-Version: 1.0 To: gengdongjiu CC: "christoffer.dall@linaro.org" , "marc.zyngier@arm.com" , "linux@armlinux.org.uk" , "catalin.marinas@arm.com" , "rjw@rjwysocki.net" , "bp@alien8.de" , "robert.moore@intel.com" , "lv.zheng@intel.com" , "corbet@lwn.net" , "will.deacon@arm.com" , "linux-doc@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "kvmarm@lists.cs.columbia.edu" , "linux-acpi@vger.kernel.org" , "devel@acpica.org" , Huangshaoyu Subject: Re: [PATCH v9 5/7] arm64: kvm: Introduce KVM_ARM_SET_SERROR_ESR ioctl References: <0184EA26B2509940AA629AE1405DD7F201A9E8EA@DGGEMA503-MBS.china.huawei.com> <5A70C5A0.1050600@arm.com> In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi gengdongjiu, On 05/02/18 06:19, gengdongjiu wrote: > On 2018/1/31 3:21, James Morse wrote: >> On 24/01/18 20:06, gengdongjiu wrote: >>>> On 06/01/18 16:02, Dongjiu Geng wrote: >>>>> The ARM64 RAS SError Interrupt(SEI) syndrome value is specific to the >>>>> guest and user space needs a way to tell KVM this value. So we add a >>>>> new ioctl. Before user space specifies the Exception Syndrome Register >>>>> ESR(ESR), it firstly checks that whether KVM has the capability to set >>>>> the guest ESR, If has, will set it. Otherwise, nothing to do. >>>>> >>>>> For this ESR specifying, Only support for AArch64, not support AArch32. >>>> >>>> After this patch user-space can trigger an SError in the guest. If it wants to migrate the guest, how does the pending SError get migrated? >>>> >>>> I think we need to fix migration first. Andrew Jones suggested using >>>> KVM_GET/SET_VCPU_EVENTS: >>>> https://www.spinics.net/lists/arm-kernel/msg616846.html >>>> >>>> Given KVM uses kvm_inject_vabt() on v8.0 hardware too, we should cover systems without the v8.2 RAS Extensions with the same API. I >>>> think this means a bit to read/write whether SError is pending, and another to indicate the ESR should be set/read. >>>> CPUs without the v8.2 RAS Extensions can reject pending-SError that had an ESR. >>> >>> For the CPUs without the v8.2 RAS Extensions, its ESR is always 0, >>> we only can inject a SError with ESR 0 to guest, cannot set its ESR. >> >> 0? It's always implementation-defined. On Juno it seems to be always-0, but >> other systems may behave differently. (Juno may generate another ESR value when >> I'm not watching it...) > For the armv8.0 cpu without RAS Extensions, it does not have vsesr_el2, so when > guest take a virtual SError, > its ESR is 0, can not control the virtual SError's syndrom value, it does not have > such registers to control that. My point was its more nuanced than this: the ARM-ARM's TakeVirtualSErrorException() pseudo-code lets virtual-SError have an implementation defined syndrome. I've never seen Juno generate anything other than '0', but it might do something different on a thursday. The point? We can't know what a CPU without the RAS extensions puts in there. Why Does this matter? When migrating a pending SError we have to know the difference between 'use this 64bit value', and 'the CPU will generate it'. If I make an SError pending with ESR=0 on a CPU with VSESR, I can't migrated to a system that generates an impdef SError-ESR, because I can't know it will be 0. > Does Juno not have RAS Extension? It's two types of v8.0 CPU, no RAS extensions. > if yes, I think we can only inject an SError, but can not change its ESR value, > because it does not have vsesr_el2. I agree, this means we need to be able to tell the difference between 'pending' and 'pending with this ESR'. >> Just because we can't control the ESR doesn't mean injecting an SError isn't >> something user-space may want to do. > yes, we may need to support user-space injects an SError even through CPU does not have RAS Extension. > >> If we tackle migration of pending-SError first, I think that will give us the >> API to create a new pending SError with/without an ESR as appropriate. > > sure, we should. Last week, I checked the KVM_GET/SET_VCPU_EVENTS IOCTL, it should meet our > migration requirements Great! Thanks, James >>> The IOCTL KVM_GET/SET_VCPU_EVENTS has been used by X86. >> >> We would be re-using the struct to have values with slightly different meanings. >> But for migration the upshot is the same, call KVM_GET_VCPU_EVENTS on one >> system, and pass the struct to KVM_SET_VCPU_EVENTS on the new system. If we're >> lucky Qemu may be able to do this in shared x86/arm64 code. >> > Thanks for the reminder, I know your meaning. > In the x86, the kvm_vcpu_events includes exception/interrupt/nmi/smi. For the RAS, we > only involves the exception, so Qemu handling logic is different. Anyway, I will try to > share code for the two platform in Qemu. > > > /* for KVM_GET/SET_VCPU_EVENTS */ > struct kvm_vcpu_events { > struct { > __u8 injected; > __u8 nr; > __u8 has_error_code; > __u8 pad; > __u32 error_code; > } exception; > struct { > __u8 injected; > __u8 nr; > __u8 soft; > __u8 shadow; > } interrupt; > struct { > __u8 injected; > __u8 pending; > __u8 masked; > __u8 pad; > } nmi; > __u32 sipi_vector; > __u32 flags; > struct { > __u8 smm; > __u8 pending; > __u8 smm_inside_nmi; > __u8 latched_init; > } smi; > __u32 reserved[9]; > }; >