From patchwork Mon Nov 18 09:35:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Carstens X-Patchwork-Id: 3195811 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6DAD69F3AE for ; Mon, 18 Nov 2013 09:37:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 47AA6206A1 for ; Mon, 18 Nov 2013 09:37:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 23DB82069F for ; Mon, 18 Nov 2013 09:37:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751418Ab3KRJhQ (ORCPT ); Mon, 18 Nov 2013 04:37:16 -0500 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:53639 "EHLO e06smtp16.uk.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751221Ab3KRJhJ (ORCPT ); Mon, 18 Nov 2013 04:37:09 -0500 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Nov 2013 09:37:06 -0000 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp16.uk.ibm.com (192.168.101.146) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 18 Nov 2013 09:37:04 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9500417D8110; Mon, 18 Nov 2013 09:35:39 +0000 (GMT) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps4076.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id rAI9Zh7b60031196; Mon, 18 Nov 2013 09:35:43 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id rAI9Zst7030494; Mon, 18 Nov 2013 02:35:56 -0700 Received: from localhost (dyn-9-152-212-74.boeblingen.de.ibm.com [9.152.212.74]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id rAI9Zs6P030482; Mon, 18 Nov 2013 02:35:54 -0700 Date: Mon, 18 Nov 2013 10:35:55 +0100 From: Heiko Carstens To: Gleb Natapov Cc: Geert Uytterhoeven , Chris Mason , Linus Torvalds , linux-btrfs , lkml , Dulshani Gunawardhana , Paolo Bonzini , Mark Brown , Catalin Marinas , Will Deacon Subject: Re: [GIT PULL] Btrfs Message-ID: <20131118093555.GA4192@osiris> References: <20131114171952.3802.93244@localhost.localdomain> <20131115113216.GA7777@osiris> <20131115122131.3802.25439@localhost.localdomain> <20131115134019.3802.51473@localhost.localdomain> <20131115145723.GB7777@osiris> <20131117093604.GT2008@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20131117093604.GT2008@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13111809-3548-0000-0000-0000072D0DBE Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Sun, Nov 17, 2013 at 11:36:04AM +0200, Gleb Natapov wrote: > On Fri, Nov 15, 2013 at 03:57:23PM +0100, Heiko Carstens wrote: > > On Fri, Nov 15, 2013 at 02:42:08PM +0100, Geert Uytterhoeven wrote: > > > I was just going to comment that > > > > > > + const void *zero_page = (const void *) page_to_phys(ZERO_PAGE(0)); > > > > > > won't fly. You can't just cast a physical address to "void *". > > > > Ouch.. I think that only works on s390 because we have a 1:1 mapping for > > physical to virtual addresses in kernel space due to our split address spaces. > > > > So for btrfs and kvm it should be page_to_virt(), and for the dma_map_single() > > case I have no idea. :) > Can you send updated patch for kvm please? See below. page_to_virt() is only defined for a couple of architectures, so I used __va(page_to_phys()) instead. I tested the patch on s390 only... From b19687bad7e878aaed6edb786a22c6b05e886b97 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Mon, 18 Nov 2013 10:05:57 +0100 Subject: [PATCH] kvm: kvm_clear_guest_page(): fix empty_zero_page usage Using the address of 'empty_zero_page' as source address in order to clear a page is wrong. On some architectures empty_zero_page is only the pointer to the struct page of the empty_zero_page. Therefore the clear page operation would copy the contents of a couple of struct pages instead of clearing a page. For kvm only arm64 is affected by this bug. To fix this use the ZERO_PAGE macro instead which will return the struct page address of the empty_zero_page on all architectures. Signed-off-by: Heiko Carstens --- virt/kvm/kvm_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 662f34c3287e..a0aa84b5941a 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1615,8 +1615,9 @@ EXPORT_SYMBOL_GPL(kvm_read_guest_cached); int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len) { - return kvm_write_guest_page(kvm, gfn, (const void *) empty_zero_page, - offset, len); + const void *zero_page = (const void *) __va(page_to_phys(ZERO_PAGE(0))); + + return kvm_write_guest_page(kvm, gfn, zero_page, offset, len); } EXPORT_SYMBOL_GPL(kvm_clear_guest_page);