Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7400788rwp; Tue, 18 Jul 2023 15:00:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlEWGmtDQHvFMlNX1yqMvBb2BsYyRSFoNj027mH8vGVUaawN4b07g3lZnibol8EeZEe+DAFg X-Received: by 2002:a05:6a00:1509:b0:682:4801:93d3 with SMTP id q9-20020a056a00150900b00682480193d3mr17213373pfu.31.1689717637945; Tue, 18 Jul 2023 15:00:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689717637; cv=none; d=google.com; s=arc-20160816; b=OtDqykW1IifX6rItPGcAlYTuwDRe7ZqHHmZPgAQGPKzYGrr2ITRHI7fJrUdgCpCu9a fkmE+3BTmqSDTyR1xJIe7+QFP/dupPOcjhn2SDTO+/49uqhCG2OGXFYNzfHrgAxWfb9W HhiNlG8OdEJiLueuTPobiQ4WHYuGqL9WkAbUu47LuYSdpuJKNV+ftJjyDHjFdf5eGs4R iJb3/d94Pe7zDK1NGkN91LWpORc/wyLi3FdxrvjG//lkhStQ90OFU0ujppYYKe5LXy7t qjqhd/phRE8HmzPARcDUwPib6kcX1z/4UUyXRN0zYMiFGoNstCB7KR3bzm8g1eOKv8I/ PzLQ== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=BxIOPLK09dEzKPiTWLGlgHqf+uwa1J2ecYmZ9dLVzKg=; fh=hMV+mtlsJvcyjTJTUYSmxFecCKL83Lw/BTgebaFJrWU=; b=ubKwgXPvRALC5zGNN588OoPwtVxD/Dvd6cmBWtPnFH23/qz+7nVBN0oA+kilu/dvna Mt2PopCPZvK7rV8TNTATlqmsvjJPZ35h46jYwiaI8unl4Eehxchi1BuSfBgF17+kSAL/ gby6nzqYCeoRrLH5KQZs0ncuT2WPJ62OMkLyry6OnUFXf7ifZMmEhViiRCVU2nUMYRS2 TqtE5galPGeN2oUyEas6vdRc4D5vrhMgomO2sKXdSW/WFUJvVn3r0i79aMYVTUiETNj5 fsz+bAxpFYur2RjLsHu4rvlvEjF151zsE6UmJSUpBIKDR52BtuDYbB1MDFeshxJN2IBI MY7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=jJC08jRY; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fd41-20020a056a002ea900b006797c2c00besi2195381pfb.144.2023.07.18.15.00.23; Tue, 18 Jul 2023 15:00:37 -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=@intel.com header.s=Intel header.b=jJC08jRY; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230098AbjGRVg6 (ORCPT + 99 others); Tue, 18 Jul 2023 17:36:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbjGRVg5 (ORCPT ); Tue, 18 Jul 2023 17:36:57 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB3D9C0; Tue, 18 Jul 2023 14:36:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689716216; x=1721252216; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=1BDw+qUZlFSHxjhbgyBlkEgjL+F0zoRSb4egK/Yp7FI=; b=jJC08jRYLMdM+gxKn5rcJ9uVs6X8fknO/wjmQDHvvzQbAxAA5/t2VBPn hlBFgEHhL9D3vaU4bd/UqI1EHcZauxxqyy72579xeRGChRouZ0/7watek u8mTdvoLNllveXneHr4+jIfuzIsEu7Zs1IVw/ALqAGs/Q0jge14vh4kyM jGs5+H8Qw91v27JWKL1hHjrMeSKVXjrXv7sccfU7ANWk9uCSspzl2azIX 3Rk+7aHuy2UNAxE3Ix+asuSn8nGRrJF8kcrzIzhyhMupoPB+F/AY8HIpF ba8YexXrNOqwOkxDHWxW8ZG9NkoW5t/YrXp8lWRDvVRODrTIcVuhOB/sj g==; X-IronPort-AV: E=McAfee;i="6600,9927,10775"; a="432500416" X-IronPort-AV: E=Sophos;i="6.01,215,1684825200"; d="scan'208";a="432500416" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2023 14:36:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10775"; a="1054464383" X-IronPort-AV: E=Sophos;i="6.01,215,1684825200"; d="scan'208";a="1054464383" Received: from unknown (HELO [10.209.37.195]) ([10.209.37.195]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2023 14:36:54 -0700 Message-ID: Date: Tue, 18 Jul 2023 14:36:53 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] x86/sgx: fix a NULL pointer Content-Language: en-US To: Haitao Huang , Jarkko Sakkinen , dave.hansen@linux.intel.com, linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Cc: kai.huang@intel.com, reinette.chatre@intel.com, kristen@linux.intel.com, seanjc@google.com, stable@vger.kernel.org References: <20230717202938.94989-1-haitao.huang@linux.intel.com> From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 On 7/18/23 14:22, Haitao Huang wrote: > I agree this is the race. But for this to happen, that is at #1 you have > only one non-SECS page left so #3 can happen. That means it is already > high pressure I think our definitions of memory pressure differ. Pressure is raised by allocations and dropped by reclaim. This raise->drop cycle is (or should be) time-limited and can't take forever. The reclaim either works in a short period of time or something dies. If allocations are transient, pressure is transient. Let's say a pressure blip (a one-time event) comes along and pages out that second-to-last page. That's pretty low pressure. Years pass. The enclave never gets run. Nothing pages the second-to-last page back in. A second pressure blip comes along. The SECS page gets paged out. That's two pressure blips in, say 10 years. Is that "high pressure"? > because reclaimer has swapped all other non-SECS. > In my example of two enclaves of 5 non-EPC pages. #3 won't happen > because you don't reach #1 with only one non-SECS left.