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 59E3A22256B for ; Thu, 9 Jan 2025 13:38:36 +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=1736429918; cv=none; b=jo3sHxZUz2FwfxEVZUefFPRAbeyVk2JZyeJbX4OpVs+jgIbqjpiTVpJEYLAU5Th7GnLLB4N+yRUiHfL8qVsgcIWtqzT/0UKN4DBMwmYx9kYNqhNgy84ZEHcV6FOG5w1jgnebhthtHvtHOcmypQYRaJ9ny/rX+GDooCji0FMQAVE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429918; c=relaxed/simple; bh=iNT9KPtrkMdcv/JnCsg0+6j7kTEB+dZG7xYjFTS5aX8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XtWUWKxJOnw891pLgmhp5Sc/yGMgAd349z2XuF8LibFjvKPJF6fPjUmNPUCl2l+kJwOzDxrsErcrZfngK25qCobQKMn+TuTDDlyx7bXjD36Za2b9dOU5tQPK9oPdfuzUNQGFSbSaFWJUIRUZciGKFVMw1vWm4NS9Ve6jubDCvNM= 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=JSW3sq8x; 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="JSW3sq8x" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736429915; 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: in-reply-to:in-reply-to:references:references; bh=Y4qkNvDxtryDJuaOhZabXXDqOZ28SJd16eOJBotltio=; b=JSW3sq8xJLjb4Vl6ksoDTWIznV4+LcD+clQYbfkqjlgCiC2CWEWFEnO7nktNK6aEE/4xmm f2eGnT3AHKZpmWRKhTzkARy9kriHckkIIZynSNeU05jMJYMkePp9pCuGPFMxol6jLQOvfB q1jr6Zkt9DtSnmESL7BVkDU7GFySEPo= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-271-P-23zBPzMtSdXSsDoAioeQ-1; Thu, 09 Jan 2025 08:38:33 -0500 X-MC-Unique: P-23zBPzMtSdXSsDoAioeQ-1 X-Mimecast-MFC-AGG-ID: P-23zBPzMtSdXSsDoAioeQ Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-aa67f18cb95so91683066b.1 for ; Thu, 09 Jan 2025 05:38:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736429911; x=1737034711; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y4qkNvDxtryDJuaOhZabXXDqOZ28SJd16eOJBotltio=; b=VL2juWTtTclu7tk7rE0EipjtO56at3IsY03tWTYj4PPg0WHIa0/+deu5C11cqww4kU Tsy2rttGqZin2f1iwmhq6RDCxamFPv6i0vNMixSsRvSdI6Bnb3esMAkqPHSEb8Yys22b 1yK0VvLtPdgiJrSnjuxB0Jy897a60satuLUnB0gdq/lyblZ4YwKrmYvLEgQg8S2l07km sNuTMLnsTV1BGbfroNzlQJb28WK/k91Pzy8u7yJPhtXq6yD4jwrjpDqkIOd9bIGtdEyV BnCeM/WoNwGw1sqwW06EFQg2uRr0hwLmjtJbJAK9NwbBmtTqyH4iqGZRPc0nb2rIj8k5 aLCg== X-Gm-Message-State: AOJu0YyKnfccYPpSr1UF4Waa4ar9iPfbb21bc8bQ/a923l+q34AmoDMW tgJqNq/oso9s2YNU09kkyTjxcJ/6iymJgJEGCf47sdu5bujexoJjQiJ+Tz+07d7m5kqXK3LXcS+ RQov0idigVz+KLeB7h7wZRfmqHYPgruwuPYTvsvI6k1STdyxUPiImu2ECxw3nzs4CEGIWE9mYXM 5/v/i4OqXTmQCRkyuS6uBti9Ibao64gewkwao8tjKGjKdfEvvU X-Gm-Gg: ASbGncs1YAyHJoJ4mlpJUIShFQnhf6d9FdAvUSBC2FWhnS4fH4FP5JfSCAVbLbOCSsv RYg9Mh71Ei40oBw8ulkLjaMhyvno1Eq4XtWALmssTN2EaxiNh+WcaQeivbgd6IRnyMHztslCByG gM6InsIcTJ0ozzLYyZ498LXqNf2BaL9JzvfEzP2QoDv2UoCW3R9qkhHplIee9HnWJiWKHDlvjfz tHUEiX+PqJNIBTvxYYLC++1flieX3wFF+Wh3fMBPDkeGONw+tmu6HNLXX2T X-Received: by 2002:a17:907:97c6:b0:aaf:208:fd3f with SMTP id a640c23a62f3a-ab2ab558911mr610032466b.13.1736429911084; Thu, 09 Jan 2025 05:38:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IEcNnAC+O5NQsf3e6ZbNH5VgDVjtZpeWPQB3s6uy9MQKvp52Beiu2u+bl2BWL3zXg+RcIfN2Q== X-Received: by 2002:a17:907:97c6:b0:aaf:208:fd3f with SMTP id a640c23a62f3a-ab2ab558911mr610029466b.13.1736429910681; Thu, 09 Jan 2025 05:38:30 -0800 (PST) Received: from [192.168.10.47] ([151.62.105.73]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab2c90d6838sm74386766b.55.2025.01.09.05.38.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 05:38:29 -0800 (PST) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: oliver.upton@linux.dev, Will Deacon , Anup Patel , Andrew Jones , seanjc@google.com, linuxppc-dev@lists.ozlabs.org, regressions@lists.linux.dev, Christian Zigotzky Subject: [PATCH 4/5] KVM: e500: map readonly host pages for read Date: Thu, 9 Jan 2025 14:38:16 +0100 Message-ID: <20250109133817.314401-5-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250109133817.314401-1-pbonzini@redhat.com> References: <20250109133817.314401-1-pbonzini@redhat.com> 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 nonchalantly passing NULL. If the host page permissions do not include writability, the shadow TLB entry is forcibly mapped read-only. Reported-by: Christian Zigotzky Signed-off-by: Paolo Bonzini --- arch/powerpc/kvm/e500_mmu_host.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c index e332a10fff00..7752b7f24c51 100644 --- a/arch/powerpc/kvm/e500_mmu_host.c +++ b/arch/powerpc/kvm/e500_mmu_host.c @@ -379,6 +379,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, unsigned long slot_start, slot_end; pfnmap = 1; + writable = vma->vm_flags & VM_WRITE; start = vma->vm_pgoff; end = start + @@ -454,7 +455,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, if (likely(!pfnmap)) { tsize_pages = 1UL << (tsize + 10 - PAGE_SHIFT); - pfn = __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, NULL, &page); + pfn = __kvm_faultin_pfn(slot, gfn, FOLL_WRITE, &writable, &page); if (is_error_noslot_pfn(pfn)) { if (printk_ratelimit()) pr_err("%s: real page not found for gfn %lx\n", @@ -499,7 +500,7 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, } } - kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg, true); + kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg, writable); kvmppc_e500_setup_stlbe(&vcpu_e500->vcpu, gtlbe, tsize, ref, gvaddr, stlbe); writable = tlbe_is_writable(stlbe); -- 2.47.1