From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F29A2C4332F for ; Thu, 8 Dec 2022 19:03:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EFuu5YdxTSR/Jiw6ivfoNzADiy9+gaD5rIpTRPm29zo=; b=aYKTRVtJlOSQW9 erV28dowStwauJcFeOLexmPFojeeNab3QLFip3H1kcHkAJHOIbdTtLUsCxLl6nrCfHgCgSqAZxtQs 84ghJuzyt7d23NgVgLe+rIbLi8RE4/ICtE6C0VVo69UZSkaFxwbLAX6BJlvEjPy6l6w1MX6kvx5GG Jvh+VHc1UvIZA0vs7ceqft7ju5kpa29tuQxjjz3gvIMOiyFS42DAx0QLZkwR886CM/KrKA6BJH3j5 7+OpVfZp8+U/SrMmAov70v7B79Ya5s53z/Nb1tRXYAhpaWyyQ6Ojs7tmubxl2EmnvupBpVKeBO6pF w7M2TR9p8QpVnWwNKTEg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p3M9z-008yPB-OY; Thu, 08 Dec 2022 19:02:20 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p3M9q-008y0W-GG for linux-arm-kernel@lists.infradead.org; Thu, 08 Dec 2022 19:02:15 +0000 Received: by mail-pj1-x1033.google.com with SMTP id t17so2449076pjo.3 for ; Thu, 08 Dec 2022 11:02:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=+qj/hgsudAsSQeQjwLgM7Er96xTBcPfba5POCbUPtwA=; b=OZuydJPyQ7RHibQ69DK8aLxuHXUNvSGO5obZIQv0KYH19XsbkQC1aG0MlCb9PZfWCX WANqzP3qFui9udWh/088tR7qgAyIVZwDGFo6GozIXGCty6MttKLjyVr6Wzvr+QVAH/AF 6CxPB1pZJI35PWxIXsUk570n/LIoeqNl0mKpWtUxBSngeOqY8WIEIU+b2qKpqC3mmnRL Dve6GGtJOchEaa/us9OjD0lEqWy44kquFqcZs3uIXXlcOMAgUVCnkwQK7KWcE65oXveM 9+OVSAKOLGY8YdAZ+y4D4olEzaD3AMRaIj6tQqRenz46uiGZ8DQ8PpV10U+fjEiVoNcZ 6j8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+qj/hgsudAsSQeQjwLgM7Er96xTBcPfba5POCbUPtwA=; b=8RWx780loW+Eyzf7LNr0nIxy9Vw+n/iLEqkNRTEtAZYr1y2qyfmcQFcdH9bQONTwjB r7Pomu1x4JFLeJL2K0oWUhf/iFmsZXmOQJmWBSHJD6T5jgCFXSCxAuqL3NL/UnF6WC3b GEqV5sZ6AGiYCUkIGr1ihDzRAm7mLjIuA6/vXMbo/Uo91Z8tT2LM5/LvCARtRgVn8SHF kv/pqJUgeIq7VDngnJq6JJdaX6gZGBw7zoCeY4GjGmX8ZCKkTFMDWMwBzDY60H495/qI NmBBQ8tTEpB+ykTdpJhWgKcAZwrJTU4/cRtCRiLOVbQxDRN8p6gYBdH/GLMLTOX89Kul UD5Q== X-Gm-Message-State: ANoB5pk6FAk630Fr5hws0a9e4fscPeXLTtaEyB/i+CoQCSK1A1VCr+Y9 hgdTfCnW+9iQ7tKl/uGXB/IZqA== X-Google-Smtp-Source: AA0mqf4AGgSjtYnu5c8NEL23WDXyqgRNekWyEeU6QVFPhXeyxHMI+VeQ/2t+hiPXrAUk+4iEU+mr5g== X-Received: by 2002:a17:902:7402:b0:189:58a8:282 with SMTP id g2-20020a170902740200b0018958a80282mr1565905pll.3.1670526121972; Thu, 08 Dec 2022 11:02:01 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id u17-20020a170902e81100b0018996404dd5sm5999822plg.109.2022.12.08.11.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 11:02:01 -0800 (PST) Date: Thu, 8 Dec 2022 19:01:57 +0000 From: Sean Christopherson To: Ricardo Koller Cc: Oliver Upton , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Paolo Bonzini , Shuah Khan , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, kvmarm@lists.linux.dev, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/4] KVM: selftests: Setup ucall after loading program into guest memory Message-ID: References: <20221207214809.489070-1-oliver.upton@linux.dev> <20221207214809.489070-3-oliver.upton@linux.dev> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221208_110210_571638_6656B670 X-CRM114-Status: GOOD ( 27.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Dec 08, 2022, Ricardo Koller wrote: > On Thu, Dec 08, 2022 at 12:37:23AM +0000, Oliver Upton wrote: > > On Thu, Dec 08, 2022 at 12:24:20AM +0000, Sean Christopherson wrote: > > > > Even still, that's just a kludge to make ucalls work. We have other > > > > MMIO devices (GIC distributor, for example) that work by chance since > > > > nothing conflicts with the constant GPAs we've selected in the tests. > > > > > > > > I'd rather we go down the route of having an address allocator for the > > > > for both the VA and PA spaces to provide carveouts at runtime. > > > > > > Aren't those two separate issues? The PA, a.k.a. memslots space, can be solved > > > by allocating a dedicated memslot, i.e. doesn't need a carve. At worst, collisions > > > will yield very explicit asserts, which IMO is better than whatever might go wrong > > > with a carve out. > > > > Perhaps the use of the term 'carveout' wasn't right here. > > > > What I'm suggesting is we cannot rely on KVM memslots alone to act as an > > allocator for the PA space. KVM can provide devices to the guest that > > aren't represented as memslots. If we're trying to fix PA allocations > > anyway, why not make it generic enough to suit the needs of things > > beyond ucalls? > > One extra bit of information: in arm, IO is any access to an address (within > bounds) not backed by a memslot. Not the same as x86 where MMIO are writes to > read-only memslots. No idea what other arches do. I don't think that's correct, doesn't this code turn write abort on a RO memslot into an io_mem_abort()? Specifically, the "(write_fault && !writable)" check will match, and assuming none the the edge cases in the if-statement fire, KVM will send the write down io_mem_abort(). gfn = fault_ipa >> PAGE_SHIFT; memslot = gfn_to_memslot(vcpu->kvm, gfn); hva = gfn_to_hva_memslot_prot(memslot, gfn, &writable); write_fault = kvm_is_write_fault(vcpu); if (kvm_is_error_hva(hva) || (write_fault && !writable)) { /* * The guest has put either its instructions or its page-tables * somewhere it shouldn't have. Userspace won't be able to do * anything about this (there's no syndrome for a start), so * re-inject the abort back into the guest. */ if (is_iabt) { ret = -ENOEXEC; goto out; } if (kvm_vcpu_abt_iss1tw(vcpu)) { kvm_inject_dabt(vcpu, kvm_vcpu_get_hfar(vcpu)); ret = 1; goto out_unlock; } /* * Check for a cache maintenance operation. Since we * ended-up here, we know it is outside of any memory * slot. But we can't find out if that is for a device, * or if the guest is just being stupid. The only thing * we know for sure is that this range cannot be cached. * * So let's assume that the guest is just being * cautious, and skip the instruction. */ if (kvm_is_error_hva(hva) && kvm_vcpu_dabt_is_cm(vcpu)) { kvm_incr_pc(vcpu); ret = 1; goto out_unlock; } /* * The IPA is reported as [MAX:12], so we need to * complement it with the bottom 12 bits from the * faulting VA. This is always 12 bits, irrespective * of the page size. */ fault_ipa |= kvm_vcpu_get_hfar(vcpu) & ((1 << 12) - 1); ret = io_mem_abort(vcpu, fault_ipa); goto out_unlock; } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel