Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp669598ybe; Thu, 5 Sep 2019 04:10:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLoOOo0N0UKWETtwByZcRFUNi1STy8PsLEmjCz9GQkT1hDZgkZnxtOi0Y6kzItdHFuTF+p X-Received: by 2002:a17:90a:c70e:: with SMTP id o14mr3287923pjt.56.1567681821981; Thu, 05 Sep 2019 04:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567681821; cv=none; d=google.com; s=arc-20160816; b=ALp9qyfYT3u4RRMaqmsUgTjsimCMYnRhH2EQcJDeKc8/cwy/7q9jQYvhszsBGs2OU7 O3AiZv54igwv7mkDuWvNfYwdtJbwgS5CNMyZqlxwq1IHo7bQKg1m0GxVyYGmaVh7AKLT An3b8LWbuB1GxPqxGHSg/YQ4jTA2H9VCzp8M3QyWc5DXHYxD6fMd+BASYp0UbETKyrsa GoI6FtBT9O8yDyzBR8tnqi1aIC0kiHU8p4DmnKT3UeiileA1I0ccuBjxuTSt0MXyXiVa 5Yxo/iziBTI73oNBlEA7d9rxEo8hix5sLopbrvvEEI36aZXBc0tQ3HI/mC7ywAVvh1+6 sblg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=aEy/J/HRTdoodRpI4aLc1UrIFmSuhYiC7T+QtIfNvBQ=; b=U3GbWlAqctlN3ZdB9JZOZ1JdMUqJrigfLeBLyecczDqI+yHvdmpg94iIt2rlumKpB4 lRl7zV3Y+IiVBlZCL0KcO+7dEl+2MEMSLRZw54YXZ3VZ68QZzaXcko/OhswELhTd4ije rI8DPr9Jj0p8yVCJr3qEr4RmXtM9ruLjjGmA+xXwmgJGSeLdVXtmlUzsTDAJDQvl3RwH m3WTLRVmdQidt9Y6Cs1RZajn7Aex1QUytRNaQnQ6VvPRp6YyZ0Q5mtAo6JjMr0Tbh1IP k41nZjS3CetjkU5MlQuYznB0p4NZVwUN3Y8taqlEp8JBFfJShcYf6OD/dmQzdGKAl6Ab jHlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=YQ0GY5em; 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 r90si1296753pjb.19.2019.09.05.04.10.04; Thu, 05 Sep 2019 04:10:21 -0700 (PDT) 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=@gmx.net header.s=badeba3b8450 header.b=YQ0GY5em; 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 S1732639AbfIEI27 (ORCPT + 99 others); Thu, 5 Sep 2019 04:28:59 -0400 Received: from mout.gmx.net ([212.227.17.22]:35529 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732628AbfIEI27 (ORCPT ); Thu, 5 Sep 2019 04:28:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1567672125; bh=t7W1mOvSdT7FOnR+iJZMPkkVrv1ufI9+MEcjVA3FqQY=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=YQ0GY5emBWtF2+ARETctDQd8UbjUSt+7ponkJxaBHMFGgOFmEG1tE3om/960jzKUP rUVbLf3mOp3FxgVDPQQ1K75Tr/3QcB4Fm96IgsC/A63irqY0fiIHircyIRjyufjxzy A86Mpka/2UoIK052efvAbgW+4tqhORzkWRRgSIIU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.123.51] ([84.118.159.3]) by mail.gmx.com (mrgmx102 [212.227.17.168]) with ESMTPSA (Nemesis) id 0M1iGk-1iPwPf0u7u-00toiu; Thu, 05 Sep 2019 10:28:45 +0200 Subject: Re: [PATCH 1/1] KVM: inject data abort if instruction cannot be decoded To: Marc Zyngier Cc: James Morse , Julien Thierry , Suzuki K Pouloze , Peter Maydell , Stefan Hajnoczi , =?UTF-8?Q?Daniel_P_=2e_Berrang=c3=a9?= , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org References: <20190904180736.29009-1-xypron.glpk@gmx.de> <86r24vrwyh.wl-maz@kernel.org> From: Heinrich Schuchardt Message-ID: <754fb77a-aace-e0aa-a5bb-a6c6bcff9890@gmx.de> Date: Thu, 5 Sep 2019 10:28:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <86r24vrwyh.wl-maz@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:eaUsm+16cI+R1zRcdIsQOLAO6sdEkj8i+rShDso7dOQJA3nRcY+ VTOE55Nsdz4pR3H8aP0fFrW8lWq9Jbia0oD9USGdOLuY7ZlGNKikVKt+zXBjIAWn3SLx4hy fqoArj8gvqB8ws48EHaCKZweAnVS/X7+AiMTNMorZ8RK6WOuEjAxko686tWkag1OK2n7h0Y ZEfc9obZitTHgvedP3CZQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:l5eBDt4PzLo=:fMWCUZGhlpaBB4ITFb8nf8 Sb/Bu/pfSLJSVhFXafFMMT65q8hZ45JMyWnskj9IypAOjK9ORc4Tm4sBI2mjTUAgXr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XFvtrVXmPHxEZfDgVNCt VfTX1cJ/HYExDBxKSTlbszXUwxQxmowXU9EWXCgeGfFAsaJ5eJK2oZ4dLmEOxoUlpSuT8IW2X d7AveIFrdMz3Tmy9R Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/5/19 10:03 AM, Marc Zyngier wrote: > [Please use my kernel.org address. My arm.com address will disappear sho= rtly] > > On Wed, 04 Sep 2019 19:07:36 +0100, > Heinrich Schuchardt wrote: >> >> If an application tries to access memory that is not mapped, an error >> ENOSYS, "load/store instruction decoding not implemented" may occur. >> QEMU will hang with a register dump. >> >> Instead create a data abort that can be handled gracefully by the >> application running in the virtual environment. >> >> Now the virtual machine can react to the event in the most appropriate >> way - by recovering, by writing an informative log, or by rebooting. >> >> Signed-off-by: Heinrich Schuchardt >> --- >> virt/kvm/arm/mmio.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/virt/kvm/arm/mmio.c b/virt/kvm/arm/mmio.c >> index a8a6a0c883f1..0cbed7d6a0f4 100644 >> --- a/virt/kvm/arm/mmio.c >> +++ b/virt/kvm/arm/mmio.c >> @@ -161,8 +161,8 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_= run *run, >> if (ret) >> return ret; >> } else { >> - kvm_err("load/store instruction decoding not implemented\n"); >> - return -ENOSYS; >> + kvm_inject_dabt(vcpu, kvm_vcpu_get_hfar(vcpu)); >> + return 1; > > How can you tell that the access would fault? You have no idea at that > stage (the kernel doesn't know about the MMIO ranges that userspace > handles). All you know is that you're faced with a memory access that > you cannot emulate in the kernel. Injecting a data abort at that stage > is not something that the architecture allows. > > If you want to address this, consider forwarding the access to > userspace. You'll only need an instruction decoder (supporting T1, T2, > A32 and A64) and a S1 page table walker (one per page table format, > all three of them) to emulate the access (having taken care of > stopping all the other vcpus to make sure there is no concurrent > modification of the page tables). You'll then be able to return the > result of the access back to the kernel. If I understand you right, the problem has to be fixed in QEMU and not in KVM. Is there an example of such a forwarding already available in QEMU? > > Of course, the best thing would be to actually fix the guest so that > it doesn't use non-emulatable MMIO accesses. In general, that the sign > of a bug in low-level accessors. My problem was to find out where in my guest (U-Boot running UEFI SCT) the problem occurred. With this patch U-Boot gave me the relative address in Shell.efi and I was able to locate what was wrong in U-Boot's UEFI implementation. Thanks for reviewing. Heinrich