Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1940731rwb; Thu, 8 Dec 2022 17:49:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf5cxz6hTIj3qqXNJXlHU72Ekr65YCb4gUi2mc3ofPCat2MzM1on+ZWeGxx7A3euzn56ixEI X-Received: by 2002:a17:90a:5d16:b0:218:bb2b:9beb with SMTP id s22-20020a17090a5d1600b00218bb2b9bebmr4114773pji.23.1670550590197; Thu, 08 Dec 2022 17:49:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670550590; cv=none; d=google.com; s=arc-20160816; b=voIDH+v0vIHvD8YfUvsr+EC0djXPnpvmL9fU0N/aUXVYOq8bGiOxlKpImGXCi5T5bf X/alYfV/ynfWzywbCcjyb5HS+Lz4EBhyXTgcd741a7etYEajI/mEKRGoYJfx2ZRW1v6t /MdKtU+90AFUJ9vnNJZyORxLXfQjHf+1VUDkj39iWowvvLh+NlXTp9ARSBFLoHtMdDTL qWg/pCFMDMAqGPrNzdVN8oEKqr4u4kzGvnC5O+bVYujL5M4bkwlx5NtD/6I8gSqMV/cZ 9hNay1wmOkq45lJzeXzLImE3ow5i1mcX5VB900HgbZjrkUCoHb9ILZQ1CJReOzgJb96m KYDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=R0W5fcABi4X+T/jYwfg3acG+mAXpKXLqoOLMcVDvb94=; b=qKmL85cIRkTudjeqJ98YdRGFR9gv7I5Rs3Uqj7VaDQihuAEI0k+FCVtqKCWUAH5Zdx /34J5xyAiWvrR6KY+aSVfUyX+rPdllhSYWAVJI6VS5lP8l8NwkO7XHchsc0oZWheUftz QV6wJue8I0ozXzUbWT/dFrDZI8sLLd72lMjnOxD/+Yt2IN9ck0n71myemLOosezkqMR5 YfyYEHigeG/OZ7c5a5kTLV5hwt9erW0EnSnorUXjm7sc7d9/SqA48EV9QaOsWEajYHZ7 DO3/jfyOATSO/fBAm6n6DBfMvEtJ+TpWixl7hMCjZNaePNFnJFOgcq7zG4IxMoIFH8GA edHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=YriPTaeI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c11-20020a17090abf0b00b002194156ef24si395695pjs.189.2022.12.08.17.49.35; Thu, 08 Dec 2022 17:49:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=YriPTaeI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbiLIBJA (ORCPT + 73 others); Thu, 8 Dec 2022 20:09:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229469AbiLIBI7 (ORCPT ); Thu, 8 Dec 2022 20:08:59 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AA8A7E818 for ; Thu, 8 Dec 2022 17:08:58 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id v13-20020a17090a6b0d00b00219c3be9830so3330001pjj.4 for ; Thu, 08 Dec 2022 17:08:58 -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=R0W5fcABi4X+T/jYwfg3acG+mAXpKXLqoOLMcVDvb94=; b=YriPTaeIiA+dLmTSSSXERGxZoMyfxJhoF2Q8RM1j7icfTqEwdCfNmwHRywZVksID9N yt3L9g633vwLWxIZEY1PievSOwRoolVjFuC2ekFqhXWDrbAgmSyOG8E61xcBei/0WmkD n3zTXHfaLve5+vNvZO0l7Nq5ja3MPhbw/Zy0/wgqCgHFNdKS3cxS/4qNYhNLqDue4ooc J5EXd9M3CGckvr5AeCg01H05bHqrWl9oIldXxZyKGqNhqjj4kHaNhCQp1c7egMM531/g 0N6aof8FoDZ0/n1nLpXmasPJ3LYaX/UAhpwEXGBjpWrXiOyYtqQVHTcsdM7gm/cVbdTY W13w== 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=R0W5fcABi4X+T/jYwfg3acG+mAXpKXLqoOLMcVDvb94=; b=F452eYe6awcdXdPu/jqUEk4TqVLrlrxVEp25k6uzg1AKBey5x2kGtJ7QkFjo72AC1a bmK0MGs1GhrkO/xxMxFAHUiXs1YEu25FS3wrKyr9o6j/NAqrytRjf9tUo49w7UTnF9xs 39vkfJHBTHkCA586wFP4cQ8W5nIwwWzv8PQfl/2c1f4SAxCE1LtaTc+hxfHZOkZ09vPS KTGlG0R+7X1jAd6sM9fa3uI+lfsvlXHzIyLtRATayEeKP5cHyecOm7vp85/RAEVQgxpG hT7/Xw66dYn0JfiAh8bjkytBMjmXRzx+yZd9bJrGueBkTKwv0NAnOUSdj1YYdQYN3dVv VCug== X-Gm-Message-State: ANoB5pnJmg5wR6C/kQRlNM/JYE++lHa0OZSjKj0BdAoAe4mMWQ4ro6pO hKUTRmF7ueBfN/NL6RaK8uRVGA== X-Received: by 2002:a17:902:d491:b0:189:858f:b5c0 with SMTP id c17-20020a170902d49100b00189858fb5c0mr1689887plg.0.1670548137442; Thu, 08 Dec 2022 17:08:57 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id n6-20020a170902d2c600b00189e1522982sm51067plc.168.2022.12.08.17.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 17:08:57 -0800 (PST) Date: Fri, 9 Dec 2022 01:08:53 +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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 08, 2022, Ricardo Koller wrote: > On Thu, Dec 08, 2022 at 07:01:57PM +0000, Sean Christopherson wrote: > > 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(). > > You are right. In fact, page_fault_test checks precisely that: writes on > RO memslots are sent to userspace as an mmio exit. I was just referring > to the MMIO done for ucall. To clarify for others, Ricardo thought that x86 selftests were already using a read-only memslot for ucalls, hence the confusion. > Having said that, we could use ucall as writes on read-only memslots > like what x86 does. +1. x86 currently uses I/O with a hardcoded port, but theoretically that's just as error prone as hardcoding a GPA, it just works because x86 doesn't have any port I/O tests. Ugh, and that made me look at sync_regs_test.c, which does its own open coded ucall. That thing is probably working by dumb luck at this point.