From patchwork Thu Apr 25 15:32:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tamas K Lengyel X-Patchwork-Id: 10917373 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B5AF0933 for ; Thu, 25 Apr 2019 15:34:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A441928BE8 for ; Thu, 25 Apr 2019 15:34:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92FB628C1D; Thu, 25 Apr 2019 15:34:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8851628BE8 for ; Thu, 25 Apr 2019 15:34:46 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hJgN2-0000ux-6A; Thu, 25 Apr 2019 15:33:08 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hJgN1-0000us-5i for xen-devel@lists.xenproject.org; Thu, 25 Apr 2019 15:33:07 +0000 X-Inumbo-ID: 6bc8f479-676f-11e9-843c-bc764e045a96 Received: from mail-io1-f68.google.com (unknown [209.85.166.68]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 6bc8f479-676f-11e9-843c-bc764e045a96; Thu, 25 Apr 2019 15:33:06 +0000 (UTC) Received: by mail-io1-f68.google.com with SMTP id h26so345127ioj.1 for ; Thu, 25 Apr 2019 08:33:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Lc21W+cP78FXS52GyrZjfGMmOgLShGWCiV6Ujqgjpw8=; b=kqsKLMhZy7CYc5d7qILEMrhDrq8TefCE1fOxgFGMpoSOCwuTR94wLlPYuOxpQZ3rZL hhYS4GnM2NLyQFfJgIXGdO2kHXABxc0MtAI+ESyjl0Fq3tTMQrEgT/d/P9dvIjUhBjFt EdGu/crCACDLLxchcAfR+p1keaf4IBfcrbOkpRHD7q9THDRNgrLo4oIWXFLMUMHU1j+P 2kSAaaqCMXxxMfnilup93hjaC5g0HOpclXS4eFHE12RpbLerumlSIb8p6wzMJpF7Fu2b qJsvfWmvN4MMb9LIMdNUmXSLGFgX8a2jObvfh3lBl1DxatbjkMRWmTR26q2CsBoSG7Af tJEw== X-Gm-Message-State: APjAAAUo3tJIj+zv0dpdFa/JNscGbBO9UadirkDQ6/SSnhejmuSYAiAt bJPCBHrVDpsadLIWlv7paIksyXnu X-Google-Smtp-Source: APXvYqwVz/ysktX9rLVc2V2stAO9Sw24Ns8lq3X5Q49Y8O4RZPNLVV4EgpHtiSMfQTErj4nMR1sxKQ== X-Received: by 2002:a05:6602:12:: with SMTP id b18mr13153070ioa.224.1556206385246; Thu, 25 Apr 2019 08:33:05 -0700 (PDT) Received: from localhost.localdomain (c-71-205-12-124.hsd1.co.comcast.net. [71.205.12.124]) by smtp.gmail.com with ESMTPSA id 2sm3589667ioz.77.2019.04.25.08.33.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Apr 2019 08:33:04 -0700 (PDT) From: Tamas K Lengyel To: xen-devel@lists.xenproject.org Date: Thu, 25 Apr 2019 09:32:50 -0600 Message-Id: <20190425153252.14795-1-tamas@tklengyel.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/3] x86/mem_sharing: aquire extra references for pages with correct domain X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Tamas K Lengyel , Wei Liu , George Dunlap , Andrew Cooper , Jan Beulich , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Patch 0502e0adae2 "x86: correct instances of PGC_allocated clearing" introduced grabbing extra references for pages that drop references tied to PGC_allocated. However, these pages are actually owned by dom_cow, resulting both sharing and unsharing breaking. Signed-off-by: Tamas K Lengyel Cc: George Dunlap Cc: Jan Beulich Cc: Andrew Cooper Cc: Wei Liu Cc: Roger Pau Monne Acked-by: Andrew Cooper --- xen/arch/x86/mm/mem_sharing.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index 5ac9d8f54c..dfc279d371 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -965,7 +965,7 @@ static int share_pages(struct domain *sd, gfn_t sgfn, shr_handle_t sh, } /* Acquire an extra reference, for the freeing below to be safe. */ - if ( !get_page(cpage, cd) ) + if ( !get_page(cpage, dom_cow) ) { ret = -EOVERFLOW; mem_sharing_page_unlock(secondpg); @@ -1171,7 +1171,7 @@ int __mem_sharing_unshare_page(struct domain *d, mem_sharing_page_unlock(page); if ( last_gfn ) { - if ( !get_page(page, d) ) + if ( !get_page(page, dom_cow) ) { put_gfn(d, gfn); domain_crash(d);