From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752151AbcGAPvo (ORCPT ); Fri, 1 Jul 2016 11:51:44 -0400 Received: from www.sr71.net ([198.145.64.142]:43799 "EHLO blackbird.sr71.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751673AbcGAPvn (ORCPT ); Fri, 1 Jul 2016 11:51:43 -0400 Subject: Re: [PATCH 6/6] x86: Fix stray A/D bit setting into non-present PTEs To: "Eric W. Biederman" , Linus Torvalds References: <20160701001209.7DA24D1C@viggo.jf.intel.com> <20160701001218.3D316260@viggo.jf.intel.com> <5775F418.2000803@sr71.net> <874m89cu61.fsf@x220.int.ebiederm.org> Cc: Linux Kernel Mailing List , the arch/x86 maintainers , linux-mm , Andrew Morton , Borislav Petkov , Andi Kleen , Michal Hocko , Dave Hansen From: Dave Hansen Message-ID: <57769188.9060708@sr71.net> Date: Fri, 1 Jul 2016 08:51:36 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <874m89cu61.fsf@x220.int.ebiederm.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/01/2016 07:25 AM, Eric W. Biederman wrote: > Linus Torvalds writes: >> > On Thu, Jun 30, 2016 at 9:39 PM, Dave Hansen wrote: >>> >> >>> >> I think what you suggest will work if we don't consider A/D in >>> >> pte_none(). I think there are a bunch of code path where assume that >>> >> !pte_present() && !pte_none() means swap. >> > >> > Yeah, we would need to change pte_none() to mask off D/A, but I think >> > that might be the only real change needed (other than making sure that >> > we don't use the bits in the swap entries, I didn't look at that part >> > at all) > It looks like __pte_to_swp_entry also needs to be changed to mask out > those bits when the swap code reads pte entries. For all of the same > reasons as pte_none. I guess that would be nice, but isn't it redundant? static inline swp_entry_t pte_to_swp_entry(pte_t pte) { ... arch_entry = __pte_to_swp_entry(pte); return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry)); } As long as __swp_type() and __swp_offset() don't let A/D through, then we should be OK. This site is the only call to __pte_to_swp_entry() that I can find in the entire codebase. Or am I missing something?