From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C125B15575D for ; Sun, 12 Jan 2025 09:55:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736675737; cv=none; b=LCiBytaTCUNhd3sgT7DGzDllbMvuOweN3kGz48NpKsOXsGdNNg5P4wmgl0TbSiOp0AN3DJoYDBMs/kqg7PApJNffpYkdmjgZFzFsZ2mQF20sztAxh5DOtpFQE0gEwvQJ0f/Y/rn8xO4TFEEiEv1DJQD0HmB6HF3fmzTzCw9E2oY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736675737; c=relaxed/simple; bh=5LgN3kghoTo+6hcMs9ps9ijUlydUFsGCZ5ZnuL33xl4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=bBaPILQ5IE6x2yp7dHlJOe0OjK6Jacnl/eqBS27IWisVQ2gLPn9pdYj0iSFoc5+4I2AsVQftpLcAneDVsn7xddBNXt+9aHfHU6zQwggAHZI+B1yVu5YW+5fs2PT6efi8YieQTh/wqckLG2iO67UhNZKZp1fZxY8tN6iNIwXyLFA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZhGhgTsQ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZhGhgTsQ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736675734; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=LbPMvXWxkqoPEVecK8C7xcWKRlslEHctKLKomp3MgmA=; b=ZhGhgTsQf/NCg/wWvBkAQgDskH80c/bxe583983KSyCmraaYxVYtZChfM08xpCHeqflg19 a+woe/WtLE/Qa2XUlu1RvBajlukbc7T75c2UlcRZzdNVxawj6uneeqQglyWljEHV7WGfod tYsvrERwK/7ffzLGVCA7zjlSaSd0M7k= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-321-PVDtfPokNVqoQdtfJ5kR0g-1; Sun, 12 Jan 2025 04:55:33 -0500 X-MC-Unique: PVDtfPokNVqoQdtfJ5kR0g-1 X-Mimecast-MFC-AGG-ID: PVDtfPokNVqoQdtfJ5kR0g Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5d3f55f8f3aso4628483a12.2 for ; Sun, 12 Jan 2025 01:55:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736675731; x=1737280531; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LbPMvXWxkqoPEVecK8C7xcWKRlslEHctKLKomp3MgmA=; b=iHBQ065w9yzzm0IZwZnug/RWBnqygSXWp9r+PgSbGCILgMBKxkY8LK11S4veY/72Vj kKHiPwxnErdymMrepyD2PDddrQffw47OH53HDAaszvMossp9bvIkPRIkZUrFt+WqdCmA SSXMUiBxGy4z0eNXdz2f8jzEmr7gRCIkF3UecAWRWMMVoJLraMmPbUDaesgy69UuMRuS C03Zuhrhpad1bz9DSlXlCJW2+xYYUcHQ+hqP3l830Nr8QhTdatMe55XIV2ndYHboOdBv JnmYbfnF7dm3dw2bS3jVIOOWY/1nTSvANp0h7JV+Z35aemgB72QDuk0KSmsQ9Uq+vVD8 GKUA== X-Gm-Message-State: AOJu0YyL5+PtOkx0vKdZIa/ss9nqctC/bByd+VJF8kX7d9i6KyI99qn5 /43CS0dFlTBRoqZPZEt9XvGr3hFTupMgixqms4+2Do6f2BF1Rq8GkbycaYRMqX3b5VyOqMB5HJ3 yiXZvdurpjOz179BK+qFnUeFMOeqhkGCGcNO4fN0LzMFIJ51jwkK3zuhUJkWVtnBuZWnKzF873R vpElHwzFSHFvoLrV2sCVdsfFZd3vcaVr9UR+EgwqK1y+bJl7DK X-Gm-Gg: ASbGncum4L1gs6HE0Lih2V86/a4FIwapdd5jQhV4Idd+Q3tc/ABtzMGU0bwplYIVfmz jZcmB8HnQ+uZLeUwlEG8FEfjkz2KrILflimGxDdxsOLxhAeRVSCIZ5eDrjLcfAkyoQwrBQIoF+E AZwE2qYUXq75sSls1XrQhHLbzLXSTY5dx+626+h75/mZiJI7LPN1qNUvSaoEiMYVWK32bmeB9gQ d3F+xlbfKV3Q/Xb/uBqkvJ7O3fNjTwzKq6FtM3a6DXB0AJHm1valwZsR5Y= X-Received: by 2002:a05:6402:354c:b0:5d3:ba42:e9d6 with SMTP id 4fb4d7f45d1cf-5d972e14828mr16993860a12.17.1736675731237; Sun, 12 Jan 2025 01:55:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVLh0vGs9D36Q0IyXZ3HUQ2iOTSRSffuWayJjX6NDL6ISEn6UK/f5SUb1xvo4fnr5VPoS7bQ== X-Received: by 2002:a05:6402:354c:b0:5d3:ba42:e9d6 with SMTP id 4fb4d7f45d1cf-5d972e14828mr16993834a12.17.1736675730719; Sun, 12 Jan 2025 01:55:30 -0800 (PST) Received: from [192.168.10.3] ([151.62.105.73]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d9903c3206sm3714091a12.46.2025.01.12.01.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Jan 2025 01:55:29 -0800 (PST) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: seanjc@google.com, linuxppc-dev@lists.ozlabs.org, regressions@lists.linux.dev, Christian Zigotzky Subject: [PATCH v2 0/5] KVM: e500: map readonly host pages for read, and cleanup Date: Sun, 12 Jan 2025 10:55:22 +0100 Message-ID: <20250112095527.434998-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The new __kvm_faultin_pfn() function is upset by the fact that e500 KVM ignores host page permissions - __kvm_faultin requires a "writable" outgoing argument, but e500 KVM is passing NULL. While a simple fix would be possible that simply allows writable to be NULL, it is quite ugly to have e500 KVM ignore completely the host permissions and map readonly host pages as guest-writable. A more complete fix is present in the second to fourth patches (the first is an independent bugfix, Cc'd to stable). The last one removes the VMA-based attempts at building huge shadow TLB entries, in favor of using a PTE lookup similar to what is done for x86. This special casing of VM_PFNMAP does not work well with remap_pfn_range() as it assumes that VM_PFNMAP areas are contiguous. Note that the same incorrect logic is there in ARM's get_vma_page_shift() and RISC-V's kvm_riscv_gstage_ioremap(). Fortunately, for e500 most of the code is already there; it just has to be changed to compute the range from find_linux_pte()'s output rather than find_vma(). The new code works for both VM_PFNMAP and hugetlb mappings, so the latter is removed. If this does not work out I'll go for something like https://lore.kernel.org/kvm/Z3wnsQQ67GBf1Vsb@google.com/, but with the helper in arch/powerpc/kvm/e500_mmu_host.c. Patches 2-5 were tested by the reporter, Christian Zigotzky. Since the difference with v1 is minimal, I am going to send it to Linus today. Thanks, Paolo v1->v2: do not bother checking again that a memslot exists, instead add a fix to restore irqs even if !ptep Paolo Bonzini (5): KVM: e500: always restore irqs KVM: e500: use shadow TLB entry as witness for writability KVM: e500: track host-writability of pages KVM: e500: map readonly host pages for read KVM: e500: perform hugepage check after looking up the PFN arch/powerpc/kvm/e500.h | 2 + arch/powerpc/kvm/e500_mmu_host.c | 199 +++++++++++++------------------ 2 files changed, 85 insertions(+), 116 deletions(-) -- 2.47.1