From patchwork Wed Oct 19 08:22:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4540 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp204080wrs; Wed, 19 Oct 2022 01:44:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7T769USMvFLGYhunZiXh200IJiBIiid3oc47GbRixLqahLDbpK9qwuMlGcNG6ppYxpCbUK X-Received: by 2002:a17:902:7c8c:b0:17f:7565:4a2d with SMTP id y12-20020a1709027c8c00b0017f75654a2dmr7496327pll.65.1666169096322; Wed, 19 Oct 2022 01:44:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169096; cv=none; d=google.com; s=arc-20160816; b=OozL30WpI/e/Bi9/cI6kxAQ1R3iGivE2h6vOUCeRHBEZ3r6izbw8/hc6zfIsEwBMLG UCUA+HYhPjJI0DCXcGnw0lyKZQjXrJYhHUQarfgqe0ExZdWAVN+zpAqdR0eVbPQdqtgx fCn4xRtPyk3ti6a5aKjuY1JnLVOFXYphchMNaA5r4tRSNfDpAc2cgMoV+dduo9styjd1 q2FQY2KeR7dEAbZsdF9VXMq36fNUlV5Bx01/+6HI4Hd8ny39zl641atXIDxLNvQS3bxH EgdckoUvZ8fzIwnexH0LFiOvFXvq3CKu+julFZtTfskWicqoQjtFNhGAQac32fQdvFVq rC0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wmv422MCiy74LRydq0A1Gsjax5JTZYnSkqYnZZomJwE=; b=HyKKVc9gmFZehlhGK8q7ii3SJagOsV0ocbk9wcvw9l85gEoApOnZIDRECnUzo2uP0h sHDF+/0RJqj9A1TG2X2MWVqkYu0bim/R0x6VGG53OthR56injinGohAzE+xuEL/gx7V3 n5eGKtRE60HEDIuCG/O/prBom+xRwVwD9njuynk+B/iSl4tyhcsgOcFOgISrwhUrbld6 Qq243yN3yWR1gpre4Q4i75OFZ206EKmlCrDIohRk2HIwYBSGF7zUM0r2rNUe2JgDBN/s RIeGKu6Qt77ObEUBQs6UP0T8e1HpUiKc4HiHTSkK5et5UaND7nDJEMfeQwjGPWewOu9v GuPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GNUix2Gz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c23-20020a170902849700b00182140f0836si16381183plo.459.2022.10.19.01.44.43; Wed, 19 Oct 2022 01:44:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GNUix2Gz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230457AbiJSIo3 (ORCPT + 99 others); Wed, 19 Oct 2022 04:44:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230404AbiJSInB (ORCPT ); Wed, 19 Oct 2022 04:43:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B200383F29; Wed, 19 Oct 2022 01:40:20 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id ED066B822D6; Wed, 19 Oct 2022 08:40:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DA6FC433C1; Wed, 19 Oct 2022 08:40:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168811; bh=Y4qDb4mZNU20ip9zLWEr74fGK+TtVytsTmrTYBy7Its=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GNUix2Gzre1p4Enrfo82bU/uU6vYpnuXGXaWRlM36ZigXgxJGD/oHS6Kzck9kO6m7 hi5v7PUbMBSSMgvjVbn9g8c1quH4uo5zp51NpZG3X6Bn4CFRLu/I447/TY6/xfF33k vXP9nhV1D3P4TZze9ofJYpPAGMMmYErHtrni3f5I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Helge Deller Subject: [PATCH 6.0 060/862] parisc: Fix userspace graphics card breakage due to pgtable special bit Date: Wed, 19 Oct 2022 10:22:27 +0200 Message-Id: <20221019083252.617341641@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747104926328963049?= X-GMAIL-MSGID: =?utf-8?q?1747104926328963049?= From: Helge Deller commit 70be49f2f6223ddd2fcddb0089a40864c37e1494 upstream. Commit df24e1783e6e ("parisc: Add vDSO support") introduced the vDSO support, for which a _PAGE_SPECIAL page table flag was needed. Since we wanted to keep every page table entry in 32-bits, this patch re-used the existing - but yet unused - _PAGE_DMB flag (which triggers a hardware break if a page is accessed) to store the special bit. But when graphics card memory is mmapped into userspace, the kernel uses vm_iomap_memory() which sets the the special flag. So, with the DMB bit set, every access to the graphics memory now triggered a hardware exception and segfaulted the userspace program. Fix this breakage by dropping the DMB bit when writing the page protection bits to the CPU TLB. In addition this patch adds a small optimization: if huge pages aren't configured (which is at least the case for 32-bit kernels), then the special bit is stored in the hpage (HUGE PAGE) bit instead. That way we can skip to reset the DMB bit. Fixes: df24e1783e6e ("parisc: Add vDSO support") Cc: # 5.18+ Signed-off-by: Helge Deller Signed-off-by: Greg Kroah-Hartman --- arch/parisc/include/asm/pgtable.h | 7 ++++++- arch/parisc/kernel/entry.S | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) --- a/arch/parisc/include/asm/pgtable.h +++ b/arch/parisc/include/asm/pgtable.h @@ -192,6 +192,11 @@ extern void __update_cache(pte_t pte); #define _PAGE_PRESENT_BIT 22 /* (0x200) Software: translation valid */ #define _PAGE_HPAGE_BIT 21 /* (0x400) Software: Huge Page */ #define _PAGE_USER_BIT 20 /* (0x800) Software: User accessible page */ +#ifdef CONFIG_HUGETLB_PAGE +#define _PAGE_SPECIAL_BIT _PAGE_DMB_BIT /* DMB feature is currently unused */ +#else +#define _PAGE_SPECIAL_BIT _PAGE_HPAGE_BIT /* use unused HUGE PAGE bit */ +#endif /* N.B. The bits are defined in terms of a 32 bit word above, so the */ /* following macro is ok for both 32 and 64 bit. */ @@ -219,7 +224,7 @@ extern void __update_cache(pte_t pte); #define _PAGE_PRESENT (1 << xlate_pabit(_PAGE_PRESENT_BIT)) #define _PAGE_HUGE (1 << xlate_pabit(_PAGE_HPAGE_BIT)) #define _PAGE_USER (1 << xlate_pabit(_PAGE_USER_BIT)) -#define _PAGE_SPECIAL (_PAGE_DMB) +#define _PAGE_SPECIAL (1 << xlate_pabit(_PAGE_SPECIAL_BIT)) #define _PAGE_TABLE (_PAGE_PRESENT | _PAGE_READ | _PAGE_WRITE | _PAGE_DIRTY | _PAGE_ACCESSED) #define _PAGE_CHG_MASK (PAGE_MASK | _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_SPECIAL) --- a/arch/parisc/kernel/entry.S +++ b/arch/parisc/kernel/entry.S @@ -499,6 +499,10 @@ * Finally, _PAGE_READ goes in the top bit of PL1 (so we * trigger an access rights trap in user space if the user * tries to read an unreadable page */ +#if _PAGE_SPECIAL_BIT == _PAGE_DMB_BIT + /* need to drop DMB bit, as it's used as SPECIAL flag */ + depi 0,_PAGE_SPECIAL_BIT,1,\pte +#endif depd \pte,8,7,\prot /* PAGE_USER indicates the page can be read with user privileges, @@ -529,6 +533,10 @@ * makes the tlb entry for the differently formatted pa11 * insertion instructions */ .macro make_insert_tlb_11 spc,pte,prot +#if _PAGE_SPECIAL_BIT == _PAGE_DMB_BIT + /* need to drop DMB bit, as it's used as SPECIAL flag */ + depi 0,_PAGE_SPECIAL_BIT,1,\pte +#endif zdep \spc,30,15,\prot dep \pte,8,7,\prot extru,= \pte,_PAGE_NO_CACHE_BIT,1,%r0