Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp242670iog; Wed, 29 Jun 2022 23:12:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tZFImEuJnaduntu0Vfm3OqR1JRZTFgPrguQ/UBCPgh1zHoO/VVb1z/3nCPJJP1VXafm9FW X-Received: by 2002:a17:906:dc8f:b0:723:a62a:cd0e with SMTP id cs15-20020a170906dc8f00b00723a62acd0emr7282278ejc.444.1656569529075; Wed, 29 Jun 2022 23:12:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656569529; cv=none; d=google.com; s=arc-20160816; b=itOTCAhaTb/4qgot7zaKu9kFtfWeYKd5xzE7sulp7fYRfCgLiB7o8NdfBzEDmrpcDA 1zUW9++3HD6QowhZK03XhTh+rcBXXjEBqtH+N0vCHZwN0WlgU8n2eoPwMQlYanD6ft6o debDhtm95t4dOj3JXP80UD4yjfBR1W+hyBNvvXYlhis8XkC5Umf8h+xGBrQs3qgJkg3g WR76jpaZuh9I4mb4+el8rlbx2aVeHrDbocSU1nYk1JuOeTY9PVq1e7kb7sGHELlvsMCX ULh7v60LZmn3JKeDPG3es7QrUAD6cF/jNTru8XaBHuNCz1gTcllJBMpuNPbuZnZ95Uzw AF2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :content-language:references:cc:to:subject:from:user-agent :mime-version:date:message-id:dkim-signature; bh=ruV4lyXjfC61DA5wyReXMzsX0cqvp2zK/U29Xvr5SFM=; b=H463LWVhzQp8kFkSbSJDEhttCpkFhE7yYfc9Ujkzb6sUEjLHFKy+xtCF4iuDHjSaQj 3CKHzlldL/dvyyAdIbpx1+W+kBzvVCCQ0Ip7+LpZ0o7Ov/eYMy0VXrpPpEHr/amxTKBV lXjxTgPiFqoVpLP+J4BCQTO6GcnIRGgkswQTzyPVzNXfbzl5w2Ssn9Dkh8LcHb1tMTSh 33KpQz97bhEWCtwXd4k/grdEjmBox7hWGDWmfP08R1SiXqNVCh8zPryniBP0amrimdFE XwbtjkFv9sMuIRWb4lMkliePHKYIP7t/lSQqEZqSlC/kEFjRmrr4QxXm/t+5bmene8dq r0eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=l7nN17DB; 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=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g15-20020a056402424f00b00435d41f7623si28147049edb.13.2022.06.29.23.11.44; Wed, 29 Jun 2022 23:12:09 -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=@openvz-org.20210112.gappssmtp.com header.s=20210112 header.b=l7nN17DB; 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=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232569AbiF3F6z (ORCPT + 99 others); Thu, 30 Jun 2022 01:58:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232740AbiF3F6m (ORCPT ); Thu, 30 Jun 2022 01:58:42 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39ACA2FFCB for ; Wed, 29 Jun 2022 22:58:40 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id a4so18283780lfm.0 for ; Wed, 29 Jun 2022 22:58:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz-org.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:from:subject:to:cc :references:content-language:in-reply-to:content-transfer-encoding; bh=ruV4lyXjfC61DA5wyReXMzsX0cqvp2zK/U29Xvr5SFM=; b=l7nN17DBcsYdsVthyTe/GatE3JPafzHfBZ2cn9zPJgX+Zj0rczBbbwaKNFmcXs6IJa u73Ux9BKCuIkmWg85+KngOck8gzGG8qyfJmGBLqCuUXNe8YGOq1GTjrbTfbXMCkdtUKd CJ1Qvo0me4QK/vgoRsFTihIQ8sEVMfZDm4LLavWUeLK6ebCoZ+ZJ8N02oQiJBU4fnhBP N6Ul/zmhja8DNAAVYH62IfwmWUUyNhpvUceFXy/xswWCf1H8jCny5kKRCaAO+bqcz0Vq Kv91qfaoAty+KqYpt8ayjauiNtv6LJgr7YB6rF840s13XJjZ4TRQAD+WxkSLeiSOfJXm /kPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:from :subject:to:cc:references:content-language:in-reply-to :content-transfer-encoding; bh=ruV4lyXjfC61DA5wyReXMzsX0cqvp2zK/U29Xvr5SFM=; b=8HWHwtFa4xvbYKwrV7C3WXRr2YqB6Rh5r0tM7nXdAtDIX/Rcrym/S/t2sTRNqXWivB E7OKfbX2AXk1pEj6Qc7fF5zblUnZsxzNVK6XQAz3wIMukeSzSF6dFiLoCYhU4hvHTf3n Gesto8VnkLVL4DVq2g5ostDYLfCCXtyWyq7wMTFA07cOKkQDN3ud2cGC7xJw0ILpr5Uf VrlLU3D9GyZr0uMtALuTlct5S32fgVHUpflE0ZJ4epmUENIXY0XDTAsizWMew7MdoEVw P6o3645BA7GEL8tzBka2Owm94mjvCnaPt+JzGu/aie5kFOkmk1OPAVg3yXtR2NaB3vU+ Xo+g== X-Gm-Message-State: AJIora9DzLA95xZ7x4XkoxFyXIuwPe1v/VQtb0V/7SPek+RGmoF/UFJW l3GBDnFyw3UDAbQACe9pfRybDg== X-Received: by 2002:a05:6512:208c:b0:47f:9ed1:e8e1 with SMTP id t12-20020a056512208c00b0047f9ed1e8e1mr4637273lfr.377.1656568718457; Wed, 29 Jun 2022 22:58:38 -0700 (PDT) Received: from [192.168.1.65] ([46.188.121.129]) by smtp.gmail.com with ESMTPSA id s13-20020a05651c200d00b0025a928f3d63sm2390485ljo.61.2022.06.29.22.58.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jun 2022 22:58:38 -0700 (PDT) Message-ID: <85bd8614-9a55-3113-e5a8-b7e73f636135@openvz.org> Date: Thu, 30 Jun 2022 08:58:36 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 From: Vasily Averin Subject: [PATCH] x86/fault: ignore RSVD flag in error code if P flag is 0 To: Dave Hansen , Andy Lutomirski , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Cc: kernel@openvz.org, linux-kernel@vger.kernel.org, Konstantin Khorenko , steve.sipes@comandsolutions.com References: <9bc8de5f-fd80-57fe-0169-0ec942638299@openvz.org> Content-Language: en-US In-Reply-To: <9bc8de5f-fd80-57fe-0169-0ec942638299@openvz.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Some older Intel CPUs have errata: "Not-Present Page Faults May Set the RSVD Flag in the Error Code Problem: An attempt to access a page that is not marked present causes a page fault. Such a page fault delivers an error code in which both the P flag (bit 0) and the RSVD flag (bit 3) are 0. Due to this erratum, not-present page faults may deliver an error code in which the P flag is 0 but the RSVD flag is 1. Implication: Software may erroneously infer that a page fault was due to a reserved-bit violation when it was actually due to an attempt to access a not-present page. Workaround: Page-fault handlers should ignore the RSVD flag in the error code if the P flag is 0." This issues was observed on several nodes crashed with messages httpd: Corrupted page table at address 7f62d5b48e68 PGD 80000002e92bf067 PUD 1c99c5067 PMD 195015067 PTE 7fffffffb78b680 Bad pagetable: 000c [#1] SMP Let's follow the recommendation and will ignore the RSVD flag in the error code if the P flag is 0 Link: https://lore.kernel.org/all/aae9c7c6-989c-0261-470a-252537493b53@openvz.org Signed-off-by: Vasily Averin --- arch/x86/mm/fault.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c index fe10c6d76bac..ffc6d6bd2a22 100644 --- a/arch/x86/mm/fault.c +++ b/arch/x86/mm/fault.c @@ -1481,6 +1481,15 @@ handle_page_fault(struct pt_regs *regs, unsigned long error_code, if (unlikely(kmmio_fault(regs, address))) return; + /* + * Some older Intel CPUs have errata + * "Not-Present Page Faults May Set the RSVD Flag in the Error Code" + * It is recommended to ignore the RSVD flag (bit 3) in the error code + * if the P flag (bit 0) is 0. + */ + if (unlikely((error_code & X86_PF_RSVD) && !(error_code & X86_PF_PROT))) + error_code &= ~X86_PF_RSVD; + /* Was the fault on kernel-controlled part of the address space? */ if (unlikely(fault_in_kernel_space(address))) { do_kern_addr_fault(regs, error_code, address); -- 2.36.1