From patchwork Tue Sep 29 06:48:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Yan X-Patchwork-Id: 11804989 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AB8C6CB for ; Tue, 29 Sep 2020 06:48:41 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 467312083B for ; Tue, 29 Sep 2020 06:48:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 467312083B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kN9QU-0006wN-RH; Tue, 29 Sep 2020 06:47:50 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kN9QT-0006wI-HW for xen-devel@lists.xenproject.org; Tue, 29 Sep 2020 06:47:49 +0000 X-Inumbo-ID: 093f2dc9-556a-491a-acf9-94b34892d329 Received: from huawei.com (unknown [45.249.212.191]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 093f2dc9-556a-491a-acf9-94b34892d329; Tue, 29 Sep 2020 06:47:40 +0000 (UTC) Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id CE388C25261604B34474; Tue, 29 Sep 2020 14:47:37 +0800 (CST) Received: from huawei.com (10.175.127.227) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Tue, 29 Sep 2020 14:47:28 +0800 From: Jason Yan To: , , , , , , , , CC: Jason Yan Subject: [PATCH] x86/xen: only unlock when USE_SPLIT_PTE_PTLOCKS is true Date: Tue, 29 Sep 2020 14:48:28 +0800 Message-ID: <20200929064828.3606720-1-yanaijie@huawei.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-CFilter-Loop: Reflected X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" When USE_SPLIT_PTE_PTLOCKS is false, xen_pte_lock() actually do nothing but returns NULL. So xen_pte_unlock() should not actually unlock. Otherwise a NULL pointer dereference will be triggered. Fixes: 74260714c56d ("xen: lock pte pages while pinning/unpinning") Signed-off-by: Jason Yan --- arch/x86/xen/mmu_pv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/xen/mmu_pv.c b/arch/x86/xen/mmu_pv.c index eda78144c000..c70cbdf5c0fa 100644 --- a/arch/x86/xen/mmu_pv.c +++ b/arch/x86/xen/mmu_pv.c @@ -656,8 +656,10 @@ static spinlock_t *xen_pte_lock(struct page *page, struct mm_struct *mm) static void xen_pte_unlock(void *v) { +#if USE_SPLIT_PTE_PTLOCKS spinlock_t *ptl = v; spin_unlock(ptl); +#endif } static void xen_do_pin(unsigned level, unsigned long pfn)