From patchwork Wed Jan 16 15:42:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 1989421 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 88E26DF2A2 for ; Wed, 16 Jan 2013 15:44:55 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TvV7x-0002Ii-Jz; Wed, 16 Jan 2013 15:42:09 +0000 Received: from mail-ie0-f179.google.com ([209.85.223.179]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TvV7s-0002Gs-Vv for linux-arm-kernel@lists.infradead.org; Wed, 16 Jan 2013 15:42:06 +0000 Received: by mail-ie0-f179.google.com with SMTP id k14so2699300iea.38 for ; Wed, 16 Jan 2013 07:42:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:x-originating-ip:in-reply-to:references :date:message-id:subject:from:to:cc:content-type:x-gm-message-state; bh=6gdr91Pjl6/A4LFOvLytj5VZzP2B2CyoACMwkGY41lc=; b=dK27xi76Kh47bebkATVVX0I1fjLTlKIB3+yQrLbgQOOsRHW5otPaXNG3TCUKCmTPyJ BKRidNkD+wlLehU3gapdEu8Mbn2Cgp+q5xzykks3eqjZyaZB3mTm250oUgXKf/pzl4I6 h/DeoDe9Y/xcjwJvawt4G9sckrn64EBTUuZovCkcpbEZujZSaKJ+DfLz35eHDR+df/mx GwuPKUlLfyPMRVsCRBP5UGrQgthgO4X0GJrCbgg+71e3uoyrtFRqQCadebXqhXjiP/+s lyJNQsZ/M3CqyduuN3a+kppsLMQsXvjddOfRqBBbtJgJTY9tXYX7f1+kypkyu9XqchoV NmiQ== MIME-Version: 1.0 X-Received: by 10.50.161.232 with SMTP id xv8mr1081627igb.22.1358350922560; Wed, 16 Jan 2013 07:42:02 -0800 (PST) Received: by 10.64.37.70 with HTTP; Wed, 16 Jan 2013 07:42:02 -0800 (PST) X-Originating-IP: [72.80.83.148] In-Reply-To: <20130116121238.GS11529@redhat.com> References: <20130108183811.46302.58543.stgit@ubuntu> <20130108183924.46302.65998.stgit@ubuntu> <20130115094312.GI11529@redhat.com> <20130116121238.GS11529@redhat.com> Date: Wed, 16 Jan 2013 10:42:02 -0500 Message-ID: Subject: Re: [PATCH v5 07/14] KVM: ARM: World-switch implementation From: Christoffer Dall To: Gleb Natapov X-Gm-Message-State: ALoCoQmpS+3T7zvGN1aHP1dwLDO8CimB3nXnBwHLIYe4K36/4CSmX9ESv9IZOcsK2bz5Rgr9QEZm X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130116_104205_200719_E49B1184 X-CRM114-Status: GOOD ( 13.66 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.223.179 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Rusty Russell , kvm@vger.kernel.org, Marc Zyngier , Marcelo Tosatti , nicolas@viennot.biz, Antonios Motakis , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org [...] > >> read side RCU protects against is the memslots data structure as far >> as I can see, so the second patch pasted below fixes this for the code >> that actually accesses this data structure. > Many memory related functions that you call access memslots under the > hood and assume that locking is done by the caller. From the quick look > I found those that you've missed: > kvm_is_visible_gfn() > kvm_read_guest() > gfn_to_hva() > gfn_to_pfn_prot() > kvm_memslots() > > May be there are more. Can you enable RCU debugging in your kernel config > and check? This does not guaranty that it will catch all of the places, > but better than nothing. > yeah, I missed the call to is_visible_gfn and friends, this fixes it: is_iabt = (hsr_ec == HSR_EC_IABT); @@ -608,33 +608,43 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run) return -EFAULT; } + idx = srcu_read_lock(&vcpu->kvm->srcu); + gfn = fault_ipa >> PAGE_SHIFT; if (!kvm_is_visible_gfn(vcpu->kvm, gfn)) { if (is_iabt) { /* Prefetch Abort on I/O address */ kvm_inject_pabt(vcpu, vcpu->arch.hxfar); - return 1; + ret = 1; + goto out_unlock; } if (fault_status != FSC_FAULT) { kvm_err("Unsupported fault status on io memory: %#lx\n", fault_status); - return -EFAULT; + ret = -EFAULT; + goto out_unlock; } /* Adjust page offset */ fault_ipa |= vcpu->arch.hxfar & ~PAGE_MASK; - return io_mem_abort(vcpu, run, fault_ipa); + ret = io_mem_abort(vcpu, run, fault_ipa); + goto out_unlock; } memslot = gfn_to_memslot(vcpu->kvm, gfn); if (!memslot->user_alloc) { kvm_err("non user-alloc memslots not supported\n"); - return -EINVAL; + ret = -EINVAL; + goto out_unlock; } ret = user_mem_abort(vcpu, fault_ipa, gfn, memslot, fault_status); - return ret ? ret : 1; + if (ret == 0) + ret = 1; +out_unlock: + srcu_read_unlock(&vcpu->kvm->srcu, idx); + return ret; } static void handle_hva_to_gpa(struct kvm *kvm, --- Thanks, -Christoffer diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index c806080..f30e131 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c @@ -591,7 +591,7 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run) struct kvm_memory_slot *memslot; bool is_iabt; gfn_t gfn; - int ret; + int ret, idx; hsr_ec = vcpu->arch.hsr >> HSR_EC_SHIFT;