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 mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE658C63705 for ; Thu, 8 Dec 2022 00:24:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 3499B4B899; Wed, 7 Dec 2022 19:24:30 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@google.com Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qZ-dJE-Ak9h5; Wed, 7 Dec 2022 19:24:29 -0500 (EST) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 177ED4B871; Wed, 7 Dec 2022 19:24:29 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id C11514B871 for ; Wed, 7 Dec 2022 19:24:27 -0500 (EST) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QRVC2hSZpwOG for ; Wed, 7 Dec 2022 19:24:26 -0500 (EST) Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 9894D4B82A for ; Wed, 7 Dec 2022 19:24:26 -0500 (EST) Received: by mail-pg1-f175.google.com with SMTP id 62so17827325pgb.13 for ; Wed, 07 Dec 2022 16:24:26 -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=5SF1vNKH61lFm3hfk5Bb+AduHkT/A0rKp5e/levYr44=; b=TxrIijlKNemLsvVUWhbEvHLRzcC6kGYva9u4pTpNLVjZOSDgHPUtrPJcvdl7yu9EW3 gH0qAWTdI3PrrFOB2fKIFdUG4mm4d6rkIq/vrYaNyzOXXDSEnxnvi/pJaMS8u1deGkJD WnRUdOlmYdyFTSL9vEtdQSxevxVF+84aksPKWAT5+6Qg8xEn1zXneEe4PIIvU+fSqBWp rY2tugHj6Ftr8kAdI8/DEtGI59QMeqVjXtRQiJ8Q6a0WmVT3LbrXE1J+FzmeHSUeLAaj U1cZMf+fl9S0zPGeUYpOWdGWOwfey9jODY5T0UklNZnZj7+8fqXXltoTbKVw3qPZaYLv KoTQ== 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=5SF1vNKH61lFm3hfk5Bb+AduHkT/A0rKp5e/levYr44=; b=o1LoWn6zliZfcLJl1xuWVNoDZaXFFBpTOc3PLSqk9PKcpYBdz/9yS43pJHF+SKPQIB X5jKWKwlv2hPPkNzSnbACWHw3M0/NgKTzCac010Jx0aG1GDthbrtxNARGSo/+K/XBRIa FK6sAZZfHb63JgxjeFHjAwlxF7jZtiL1uhMN8LlhQ4clFCgwPPtct2cqh6CS+ZphME8Q PuYGd7xSTRuY7aQvhg4WbSGZ7iqhDEe5nsZ1kGB5j0o0prpZdcdd7kc7Nh1IH2GnGUyF DbnmS/QFtIzVVxd38/lt/NRR8/WWkZG818g/KZ7OEji+5i8fyZdcz5UWCRm0Q2+UxH+k Hkkg== X-Gm-Message-State: ANoB5pmH1JdaZRttLHKgZy+7kxjf+QDT8htwrbQCbGJAn+LGUqzsqTJR RVOChFdqblMJNQugMXcO2ygO7A== X-Google-Smtp-Source: AA0mqf5GIpkTgjhaAESUaXxx4LDksAwYJbd8iER/VptpemJ1xMaolNudI2qegnnhYn7rxj/a6LvllA== X-Received: by 2002:a62:b60d:0:b0:574:8995:c0d0 with SMTP id j13-20020a62b60d000000b005748995c0d0mr1460040pff.1.1670459064104; Wed, 07 Dec 2022 16:24:24 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id k85-20020a628458000000b0057725613627sm4955021pfd.142.2022.12.07.16.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 16:24:23 -0800 (PST) Date: Thu, 8 Dec 2022 00:24:20 +0000 From: Sean Christopherson To: Oliver Upton 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: Cc: kvm@vger.kernel.org, Marc Zyngier , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kvmarm@lists.linux.dev, Paolo Bonzini , Shuah Khan , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu On Thu, Dec 08, 2022, Oliver Upton wrote: > On Wed, Dec 07, 2022 at 11:57:27PM +0000, Sean Christopherson wrote: > > > diff --git a/tools/testing/selftests/kvm/aarch64/page_fault_test.c b/tools/testing/selftests/kvm/aarch64/page_fault_test.c > > > index 92d3a91153b6..95d22cfb7b41 100644 > > > --- a/tools/testing/selftests/kvm/aarch64/page_fault_test.c > > > +++ b/tools/testing/selftests/kvm/aarch64/page_fault_test.c > > > @@ -609,8 +609,13 @@ static void setup_memslots(struct kvm_vm *vm, struct test_params *p) > > > data_size / guest_page_size, > > > p->test_desc->data_memslot_flags); > > > vm->memslots[MEM_REGION_TEST_DATA] = TEST_DATA_MEMSLOT; > > > +} > > > + > > > +static void setup_ucall(struct kvm_vm *vm) > > > +{ > > > + struct userspace_mem_region *region = vm_get_mem_region(vm, MEM_REGION_TEST_DATA); > > > > > > - ucall_init(vm, data_gpa + data_size); > > > + ucall_init(vm, region->region.guest_phys_addr + region->region.memory_size); > > > > Isn't there a hole after CODE_AND_DATA_MEMSLOT? I.e. after memslot 0? > > Sure, but that's only guaranteed in the PA space. > > > The reason > > I ask is because if so, then we can do the temporarily heinous, but hopefully forward > > looking thing of adding a helper to wrap kvm_vm_elf_load() + ucall_init(). > > > > E.g. I think we can do this immediately, and then at some point in the 6.2 cycle > > add a dedicated region+memslot for the ucall MMIO page. > > 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. > There's another issue with the new ucall implementation where identity > mapping could stomp on a program segment that I'm fighting with right now > which only further highlights the problems with our (mis)management of > address spaces in selftests. Oooh, this crud: virt_pg_map(vm, mmio_gpa, mmio_gpa); Yeah, that needs to be fixed. But again, that's a separate issue, e.g. selftests can allocate a virtual address and map the read-only memslot. _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C8DB7E for ; Thu, 8 Dec 2022 00:24:26 +0000 (UTC) Received: by mail-pg1-f182.google.com with SMTP id f9so17833995pgf.7 for ; Wed, 07 Dec 2022 16:24:26 -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=5SF1vNKH61lFm3hfk5Bb+AduHkT/A0rKp5e/levYr44=; b=TxrIijlKNemLsvVUWhbEvHLRzcC6kGYva9u4pTpNLVjZOSDgHPUtrPJcvdl7yu9EW3 gH0qAWTdI3PrrFOB2fKIFdUG4mm4d6rkIq/vrYaNyzOXXDSEnxnvi/pJaMS8u1deGkJD WnRUdOlmYdyFTSL9vEtdQSxevxVF+84aksPKWAT5+6Qg8xEn1zXneEe4PIIvU+fSqBWp rY2tugHj6Ftr8kAdI8/DEtGI59QMeqVjXtRQiJ8Q6a0WmVT3LbrXE1J+FzmeHSUeLAaj U1cZMf+fl9S0zPGeUYpOWdGWOwfey9jODY5T0UklNZnZj7+8fqXXltoTbKVw3qPZaYLv KoTQ== 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=5SF1vNKH61lFm3hfk5Bb+AduHkT/A0rKp5e/levYr44=; b=VGgRai/T82BenCmRQWjNgQem7pT4fcrajIBjFy6wV2dldhruegdKZ0mzgbzuOjRTQr KTn8rs+XHPCLJWMy7QPRWVMxYTZkeAnPys2Y1o6aeaDt4JCvR/hpoag0ncXYTHT10OUf NJHkg8GyRq9cibPd9xb8v3rHHMUJsb3evQdZU8IJf3V5kepDoMrHR0onPTrEdBXG2Otg jRiITTWU+k0GFJ4cqh9HPrnDGcsu61e7kJDpOW1AEtaYAsRDzGNLlNvUZOo4jOap6IBr C1dz3yn5ILcoLfX9hnSAeUrtJb6JiF2h34Pcc7doRJ3uxwXiXlwHENuT4Rt6PyuaeV7S IY/w== X-Gm-Message-State: ANoB5pnmcSKnIg79xTm9YtU5qCT/LkNstErNMwx7wkF9bvxvqj90Ivw+ Az1nVSU1XSZlkPviYwuQxzQ1NQ== X-Google-Smtp-Source: AA0mqf5GIpkTgjhaAESUaXxx4LDksAwYJbd8iER/VptpemJ1xMaolNudI2qegnnhYn7rxj/a6LvllA== X-Received: by 2002:a62:b60d:0:b0:574:8995:c0d0 with SMTP id j13-20020a62b60d000000b005748995c0d0mr1460040pff.1.1670459064104; Wed, 07 Dec 2022 16:24:24 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id k85-20020a628458000000b0057725613627sm4955021pfd.142.2022.12.07.16.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 16:24:23 -0800 (PST) Date: Thu, 8 Dec 2022 00:24:20 +0000 From: Sean Christopherson To: Oliver Upton Cc: 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, Ricardo Koller , 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> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Message-ID: <20221208002420.Pt3PVRWULV_XiPrSQUpLBazmbeTQahNHMb5NZwBFhs0@z> On Thu, Dec 08, 2022, Oliver Upton wrote: > On Wed, Dec 07, 2022 at 11:57:27PM +0000, Sean Christopherson wrote: > > > diff --git a/tools/testing/selftests/kvm/aarch64/page_fault_test.c b/tools/testing/selftests/kvm/aarch64/page_fault_test.c > > > index 92d3a91153b6..95d22cfb7b41 100644 > > > --- a/tools/testing/selftests/kvm/aarch64/page_fault_test.c > > > +++ b/tools/testing/selftests/kvm/aarch64/page_fault_test.c > > > @@ -609,8 +609,13 @@ static void setup_memslots(struct kvm_vm *vm, struct test_params *p) > > > data_size / guest_page_size, > > > p->test_desc->data_memslot_flags); > > > vm->memslots[MEM_REGION_TEST_DATA] = TEST_DATA_MEMSLOT; > > > +} > > > + > > > +static void setup_ucall(struct kvm_vm *vm) > > > +{ > > > + struct userspace_mem_region *region = vm_get_mem_region(vm, MEM_REGION_TEST_DATA); > > > > > > - ucall_init(vm, data_gpa + data_size); > > > + ucall_init(vm, region->region.guest_phys_addr + region->region.memory_size); > > > > Isn't there a hole after CODE_AND_DATA_MEMSLOT? I.e. after memslot 0? > > Sure, but that's only guaranteed in the PA space. > > > The reason > > I ask is because if so, then we can do the temporarily heinous, but hopefully forward > > looking thing of adding a helper to wrap kvm_vm_elf_load() + ucall_init(). > > > > E.g. I think we can do this immediately, and then at some point in the 6.2 cycle > > add a dedicated region+memslot for the ucall MMIO page. > > 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. > There's another issue with the new ucall implementation where identity > mapping could stomp on a program segment that I'm fighting with right now > which only further highlights the problems with our (mis)management of > address spaces in selftests. Oooh, this crud: virt_pg_map(vm, mmio_gpa, mmio_gpa); Yeah, that needs to be fixed. But again, that's a separate issue, e.g. selftests can allocate a virtual address and map the read-only memslot. 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 5FDEFC4708D for ; Thu, 8 Dec 2022 00:25:29 +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=nuFLQZtDk5U2CPZuCsIYRa3IIrofvmDFaqWz1aDKZ/E=; b=fLrpIJCgC9aH+f phnK50pgNOJ7pLBjfiS488imIzhA2T/NL0L+iktllbWZ1/Px2SV8XblScrCdzQMd2OzmVyP1tmvUm wjtf1P1W2fH20V1zqgxiCugcxk2jKbDScQNp6dK0jfHl6zmEsdx6vOH4de/MuAXMTfVo8mnrznExI lAfex+4sLmb9ZBxS+D3R/1kf9aMHMR4UCAs5+pA5MuOKt2JS1E5vN23Biece0xomp1TolvdfKcDg7 P2I7bdOXbNdHqpJm0l111EViToFhInXtkI0cLS61kqvxbbrH4CV9cvOpIfV+mWzeUqjBWY7tGcxLM 6irCy9qSdHu6nyfvdKag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p34iD-00GgIF-Jd; Thu, 08 Dec 2022 00:24:29 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p34iA-00GgGv-LO for linux-arm-kernel@lists.infradead.org; Thu, 08 Dec 2022 00:24:28 +0000 Received: by mail-pf1-x42d.google.com with SMTP id 140so18923706pfz.6 for ; Wed, 07 Dec 2022 16:24:26 -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=5SF1vNKH61lFm3hfk5Bb+AduHkT/A0rKp5e/levYr44=; b=TxrIijlKNemLsvVUWhbEvHLRzcC6kGYva9u4pTpNLVjZOSDgHPUtrPJcvdl7yu9EW3 gH0qAWTdI3PrrFOB2fKIFdUG4mm4d6rkIq/vrYaNyzOXXDSEnxnvi/pJaMS8u1deGkJD WnRUdOlmYdyFTSL9vEtdQSxevxVF+84aksPKWAT5+6Qg8xEn1zXneEe4PIIvU+fSqBWp rY2tugHj6Ftr8kAdI8/DEtGI59QMeqVjXtRQiJ8Q6a0WmVT3LbrXE1J+FzmeHSUeLAaj U1cZMf+fl9S0zPGeUYpOWdGWOwfey9jODY5T0UklNZnZj7+8fqXXltoTbKVw3qPZaYLv KoTQ== 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=5SF1vNKH61lFm3hfk5Bb+AduHkT/A0rKp5e/levYr44=; b=UE6o/bVE7P2F3t1lVWRdynRBkftZUsHNewmw/Pf2awzpHTfWRsF+uvNpFaKW7t7Ysr 2wWbAvC8GQ1SgaaZvEkzq3RN17JkyWEZranrzDvFRfTy9gCso9AmRaJZ/ZvEydhTwR6T w1KicwObsRLIsgxxIVMvW0SyWLvqRw5/1i4vo3R8UXaXEwaVObfKDgxB9VczkBDnLoAr 0PTCBqNkLpC6YTMavvmRgVCde5IM31M+Q5j27mYKFxCItDVtB991+DnyuXot5j6TpqWL 8BCAxCJeHy3O9gRHH5UEsBqRfbw1iNBXxRcdh48GqItuZ/173N5g8+mcOJmR5Rt6074w uW/Q== X-Gm-Message-State: ANoB5pmCcsYQvgsi15iN3OODB/0Gy0UATHX+kduACuVsXGMTca/g5lKe N80EEUr2JvJ12Y5fCTfPGaQ+MQ== X-Google-Smtp-Source: AA0mqf5GIpkTgjhaAESUaXxx4LDksAwYJbd8iER/VptpemJ1xMaolNudI2qegnnhYn7rxj/a6LvllA== X-Received: by 2002:a62:b60d:0:b0:574:8995:c0d0 with SMTP id j13-20020a62b60d000000b005748995c0d0mr1460040pff.1.1670459064104; Wed, 07 Dec 2022 16:24:24 -0800 (PST) Received: from google.com (7.104.168.34.bc.googleusercontent.com. [34.168.104.7]) by smtp.gmail.com with ESMTPSA id k85-20020a628458000000b0057725613627sm4955021pfd.142.2022.12.07.16.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 16:24:23 -0800 (PST) Date: Thu, 8 Dec 2022 00:24:20 +0000 From: Sean Christopherson To: Oliver Upton Cc: 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, Ricardo Koller , 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-20221207_162426_719265_CE39ED5D X-CRM114-Status: GOOD ( 23.34 ) 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, Oliver Upton wrote: > On Wed, Dec 07, 2022 at 11:57:27PM +0000, Sean Christopherson wrote: > > > diff --git a/tools/testing/selftests/kvm/aarch64/page_fault_test.c b/tools/testing/selftests/kvm/aarch64/page_fault_test.c > > > index 92d3a91153b6..95d22cfb7b41 100644 > > > --- a/tools/testing/selftests/kvm/aarch64/page_fault_test.c > > > +++ b/tools/testing/selftests/kvm/aarch64/page_fault_test.c > > > @@ -609,8 +609,13 @@ static void setup_memslots(struct kvm_vm *vm, struct test_params *p) > > > data_size / guest_page_size, > > > p->test_desc->data_memslot_flags); > > > vm->memslots[MEM_REGION_TEST_DATA] = TEST_DATA_MEMSLOT; > > > +} > > > + > > > +static void setup_ucall(struct kvm_vm *vm) > > > +{ > > > + struct userspace_mem_region *region = vm_get_mem_region(vm, MEM_REGION_TEST_DATA); > > > > > > - ucall_init(vm, data_gpa + data_size); > > > + ucall_init(vm, region->region.guest_phys_addr + region->region.memory_size); > > > > Isn't there a hole after CODE_AND_DATA_MEMSLOT? I.e. after memslot 0? > > Sure, but that's only guaranteed in the PA space. > > > The reason > > I ask is because if so, then we can do the temporarily heinous, but hopefully forward > > looking thing of adding a helper to wrap kvm_vm_elf_load() + ucall_init(). > > > > E.g. I think we can do this immediately, and then at some point in the 6.2 cycle > > add a dedicated region+memslot for the ucall MMIO page. > > 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. > There's another issue with the new ucall implementation where identity > mapping could stomp on a program segment that I'm fighting with right now > which only further highlights the problems with our (mis)management of > address spaces in selftests. Oooh, this crud: virt_pg_map(vm, mmio_gpa, mmio_gpa); Yeah, that needs to be fixed. But again, that's a separate issue, e.g. selftests can allocate a virtual address and map the read-only memslot. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel