Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1690426ybe; Tue, 3 Sep 2019 01:59:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwud0ZVx2atBcyzLZZg9mhTMRf6niM27Oy9f019C5eWGoY3aX4MKKjeMAdFDMAppHwl0Pjs X-Received: by 2002:a17:902:8f85:: with SMTP id z5mr35055043plo.328.1567501180434; Tue, 03 Sep 2019 01:59:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567501180; cv=none; d=google.com; s=arc-20160816; b=aY1SNkjyFAeej7gETcBBtwD9kJ2eicAr1S+2wCnS0EzkwK10ULKWV1nUgW/rGIfGjA 3MCl2d4oCYgHdvSZ9egwBf2ZCICCWr7R+XwVVT7p/oIbjaTQWauI26Nl/DxqsP/SQZVX A01XpijYkmtbRMF01U5OYA0iZUvf5p12Qgs8rFUzym1kW7GwFYm+b4o92G9Avi1pst76 pvR4aoJ2SKgRrD0KbfpHUaFhKrPME6L9TfEHGkOO9vksjZnsYj4Z8TEQQv8atTzvNg7r j8S9Y2fKFjJ1/zTVmSbjEykWBE158tSNK3x1xiM3+NsI3iS76tZjRU/eDLiitLdZk3ne Rvow== 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=tFqz/uC7qGlXw1E0bZFNzUPQaIxm5XOhDjIW1OaTdqQ=; b=sYC2QWblK6IBMRUlA1298wtWl2LRp8xp/oGqWwFrt89X7VpZAOx3TRwz1blJGSckRU Jo2F0FsyKqVL4m5YvfIX4XqZvjDCXWPl71D7VH1oLQ5foEbR/XQ0hhYzy+ALZPwI6GmN ZVrTPMnbn1XlqPbOHY0fknaXQuSl2SOyTOHW8Ez2AaU/Q78SXiFUJV6Jm2Mn0Ezt6LpX nZFltRN0FK16CS55mTUl7FK+DIaVxLo7VTxDqbuPkRtWJbxSStnRe6BgY0uwrz9KfAh+ xDYoVpyjQgl76R0TqgGbis6agKEItgDjAb/3i+MHL/bW2I3as/pSd6ZQn/aNIC9lfQp5 Uw8w== 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 r11si14272479pgp.390.2019.09.03.01.59.23; Tue, 03 Sep 2019 01:59:40 -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 S1728366AbfICI63 (ORCPT + 99 others); Tue, 3 Sep 2019 04:58:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33712 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725888AbfICI62 (ORCPT ); Tue, 3 Sep 2019 04:58:28 -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 741718665D; Tue, 3 Sep 2019 08:58:28 +0000 (UTC) Received: from kamzik.brq.redhat.com (unknown [10.43.2.160]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9FF160C18; Tue, 3 Sep 2019 08:58:25 +0000 (UTC) Date: Tue, 3 Sep 2019 10:58:23 +0200 From: Andrew Jones To: Anup Patel Cc: 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 v6 10/21] RISC-V: KVM: Handle MMIO exits for VCPU Message-ID: <20190903085823.s4amn27pewc54hl2@kamzik.brq.redhat.com> References: <20190829135427.47808-1-anup.patel@wdc.com> <20190829135427.47808-11-anup.patel@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190829135427.47808-11-anup.patel@wdc.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.26]); Tue, 03 Sep 2019 08:58:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 29, 2019 at 01:56:18PM +0000, Anup Patel wrote: > int kvm_riscv_vcpu_mmio_return(struct kvm_vcpu *vcpu, struct kvm_run *run) > { > - /* TODO: */ > + u8 data8; > + u16 data16; > + u32 data32; > + u64 data64; > + ulong insn; > + int len, shift; > + > + insn = vcpu->arch.mmio_decode.insn; > + > + if (run->mmio.is_write) > + goto done; > + > + len = vcpu->arch.mmio_decode.len; > + shift = vcpu->arch.mmio_decode.shift; > + > + switch (len) { > + case 1: > + data8 = *((u8 *)run->mmio.data); > + SET_RD(insn, &vcpu->arch.guest_context, > + (ulong)data8 << shift >> shift); > + break; > + case 2: > + data16 = *((u16 *)run->mmio.data); > + SET_RD(insn, &vcpu->arch.guest_context, > + (ulong)data16 << shift >> shift); > + break; > + case 4: > + data32 = *((u32 *)run->mmio.data); > + SET_RD(insn, &vcpu->arch.guest_context, > + (ulong)data32 << shift >> shift); > + break; > + case 8: > + data64 = *((u64 *)run->mmio.data); > + SET_RD(insn, &vcpu->arch.guest_context, > + (ulong)data64 << shift >> shift); > + break; > + default: > + return -ENOTSUPP; > + }; > + > +done: > + /* Move to next instruction */ > + vcpu->arch.guest_context.sepc += INSN_LEN(insn); > + As I pointed out in the last review, just moving this instruction skip here is not enough. Doing so introduces the same problem that 2113c5f62b74 ("KVM: arm/arm64: Only skip MMIO insn once") fixes for arm. Thanks, drew