Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1118548ybl; Thu, 22 Aug 2019 09:36:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxfaNzFGy/Ija8oDu7Ezs3qYwmkAKoThrjnusCXtAsN7o8msDVOM8JW9Yr+awGAXWoWhLpp X-Received: by 2002:a62:cd45:: with SMTP id o66mr90051pfg.112.1566491774951; Thu, 22 Aug 2019 09:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566491774; cv=none; d=google.com; s=arc-20160816; b=eZiyeXNDxuQnSoE9dqyK/ivhiEKKWyWw7QPyzIU2DJUvAbcrjAAOpM8aodI24FAQJd ivhZeW8mAlY7/fq6bOVByicd6sMsiaI+Ducz4HE/D3AChJZeddaIL5ftG6uoK/ibbnzH gzDeQ4edQ/GBJZwQBgo+W6B2vGcNBc4nG6YVyM9W43J2tTkGv8zB8tLttQ+L4N3VzaWl yCa5CAHFVFsDrrXBlU44NTeJ/1pKc+q2+BewGX1vgJdXAKNmTgzklWcEaL/Vw3uGCNMp qN5xJ4GnGV2n8R72gOk7irvxgpOPPz2v6oO+50V2c59PO3uONAtGTN8kkLl2yJe9ShMj y52A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=lWZSGZ7flP9lMsaEakRa8RsWnXtiYKXReMC5ycEuRg8=; b=ph9vfKudT4EP0TaMEla1dDjLe8jLCFnEW9t8hfiWHkgphtQENdvc1gkS6MNn95Yr+7 vIfM9TXqguKduJA05ki853XKLAkdF3lA7Vr9pqkYRLr5mSifRelPLoIi05dRzBEJVRWt q7bB69M4uR7MeT9Rg0Um7ZMXJpoA9tso1psgWr8C2QD8GHkHIpmiWwtwZyxPsePfeA/T hZCuCJ9N1m4jiZxQuxQSrfk+KDu1EkhAcKodbpth6dN2Y8PQGEkIgXGYr4rmItksHE35 OP6EWzMa0rUk9UwhHhFwicsRzE9bFcFEaaOPUZH6IkHVXePziUPkPcwKj/2kzH+U48Vw oxCw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a127si89225pfa.151.2019.08.22.09.36.00; Thu, 22 Aug 2019 09:36:14 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388446AbfHVMWD (ORCPT + 99 others); Thu, 22 Aug 2019 08:22:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34212 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728952AbfHVMWC (ORCPT ); Thu, 22 Aug 2019 08:22:02 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 87F277E421; Thu, 22 Aug 2019 12:22:02 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 821B460BF3; Thu, 22 Aug 2019 12:21:59 +0000 (UTC) Date: Thu, 22 Aug 2019 14:21:57 +0200 From: Andrew Jones To: Alexander Graf Cc: Anup Patel , Palmer Dabbelt , Paul Walmsley , Paolo Bonzini , Radim K , Daniel Lezcano , Thomas Gleixner , Atish Patra , Alistair Francis , Damien Le Moal , Christoph Hellwig , Anup Patel , "kvm@vger.kernel.org" , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v5 10/20] RISC-V: KVM: Handle MMIO exits for VCPU Message-ID: <20190822122157.qy3e4rhxthfustn2@kamzik.brq.redhat.com> References: <20190822084131.114764-1-anup.patel@wdc.com> <20190822084131.114764-11-anup.patel@wdc.com> <13cf8e10-3f54-a50a-0796-ecb2da4577d2@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <13cf8e10-3f54-a50a-0796-ecb2da4577d2@amazon.com> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 22 Aug 2019 12:22:02 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 22, 2019 at 02:10:48PM +0200, Alexander Graf wrote: > On 22.08.19 10:44, Anup Patel wrote: ... > > +static int emulate_load(struct kvm_vcpu *vcpu, struct kvm_run *run, > > + unsigned long fault_addr) ... > > + /* Exit to userspace for MMIO emulation */ > > + vcpu->stat.mmio_exit_user++; > > + run->exit_reason = KVM_EXIT_MMIO; > > + run->mmio.is_write = false; > > + run->mmio.phys_addr = fault_addr; > > + run->mmio.len = len; > > + > > + /* Move to next instruction */ > > + vcpu->arch.guest_context.sepc += INSN_LEN(insn); > > Doesn't that make more sense on the reentry path? What if you want to inject > an MCE on access to unmapped addresses from user space? > I agree. See commit 0d640732dbeb for arm's justification for moving the instruction skip. But also see https://patchwork.kernel.org/patch/11109063/ for a needed fix to avoid skipping the instructions multiple times. It looks like riscv's KVM_RUN ioctl would be vulnerable to that as well. Thanks, drew