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 X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3AE6C433E2 for ; Thu, 10 Sep 2020 13:10:26 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 04ED3207FB for ; Thu, 10 Sep 2020 13:10:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KjmatZW9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04ED3207FB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=i2ndwN6Gk9+EhJ5/i01vsWPh2uIjlUN5naAtTmDq3CY=; b=KjmatZW9J0y/6RhWuwmntunfL P9AFb6Mxoj/DpipzhA/zVo7rog8BK3U33AAO/LblYPFHP9jx2NRs/0u0UYLeolAgeH4l2OOlgflJO CSDMy/ptO+/VK5pGr2l+ilXNJLBuCrIQolojisjCrrIEhV+4Zv63f3Zj6BRyrJEbi9DphnMJPpGOz JuEaJ2PuCRocv2u2JzvylJ868MtkAt2H9yvUm9ZPJlWJr5JSjzJA2r1l6a6YQ3J82ndpcJIFAxbj9 xa0ni8ro9DqRa6LRNnIFoavZLhoDbzKJ2c93lv/KLXgF0N0iCPcCUFOjocCLo0VKWWpNg8vg4P5y7 KZfNhnYTw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGMK9-0003aC-GA; Thu, 10 Sep 2020 13:09:13 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGMK5-0003Yy-VU for linux-arm-kernel@lists.infradead.org; Thu, 10 Sep 2020 13:09:11 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D13F01063; Thu, 10 Sep 2020 06:09:07 -0700 (PDT) Received: from [192.168.0.110] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 958A23F66E; Thu, 10 Sep 2020 06:09:06 -0700 (PDT) Subject: Re: [PATCH v4 17/21] KVM: arm64: Convert user_mem_abort() to generic page-table API To: Will Deacon , Marc Zyngier References: <20200907152344.12978-1-will@kernel.org> <20200907152344.12978-18-will@kernel.org> <2ae77a66-9cc4-f4e1-9e98-a50d5891cf20@arm.com> <20200910105107.GA17887@willie-the-truck> From: Alexandru Elisei Message-ID: <41e4a714-138c-1132-575f-cfd8a447c7ef@arm.com> Date: Thu, 10 Sep 2020 14:10:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20200910105107.GA17887@willie-the-truck> Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200910_090910_082150_26DD0186 X-CRM114-Status: GOOD ( 17.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gavin Shan , Suzuki Poulose , Catalin Marinas , Quentin Perret , James Morse , kernel-team@android.com, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org 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 Hi, On 9/10/20 11:51 AM, Will Deacon wrote: > On Wed, Sep 09, 2020 at 06:12:29PM +0100, Marc Zyngier wrote: >> On 2020-09-09 15:20, Alexandru Elisei wrote: >>> On 9/7/20 4:23 PM, Will Deacon wrote: >>>> @@ -1610,62 +1605,31 @@ static int user_mem_abort(struct kvm_vcpu >>>> *vcpu, phys_addr_t fault_ipa, >>>> if (vma_pagesize == PAGE_SIZE && !force_pte) >>>> vma_pagesize = transparent_hugepage_adjust(memslot, hva, >>>> &pfn, &fault_ipa); >>>> - if (writable) >>>> + if (writable) { >>>> + prot |= KVM_PGTABLE_PROT_W; >>>> kvm_set_pfn_dirty(pfn); >>>> + mark_page_dirty(kvm, gfn); >>> The previous code called mark_page_dirty() only if the vma_pagesize == >>> PAGE_SIZE >>> (and writable was true, obviously). Is this supposed to fix a bug? >> No, this is actually introducing one. mark_page_dirty() checks that there is >> an >> associated bitmap, and thus only happens when writing to a single page, but >> we >> shouldn't do it for R/O memslots, which the current code avoids. It should >> be >> guarded by logging_active. > gfn_to_pfn_prot() will set "writable" to false for R/O memslots, so I think > we're good here. That also looks correct to me, gfn_to_pfn_prot() -> __gfn_to_pfn_memslot() sets *writable to false if the memslot is readonly. Marc is also right, mark_page_dirty() first checks if there's a dirty bitmap associated with the memslot, and memslot->dirty_bitmap gets allocated only if KVM_SET_USER_MEMORY_REGION was called with the KVM_MEM_LOG_DIRTY_PAGES flag set (should've checked for that before asking). Thanks, Alex _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel