From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752509AbcGASZY (ORCPT ); Fri, 1 Jul 2016 14:25:24 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:50342 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752459AbcGASZW (ORCPT ); Fri, 1 Jul 2016 14:25:22 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Dave Hansen Cc: Linus Torvalds , Linux Kernel Mailing List , the arch/x86 maintainers , linux-mm , Andrew Morton , Borislav Petkov , Andi Kleen , Michal Hocko , Dave Hansen References: <20160701001209.7DA24D1C@viggo.jf.intel.com> <20160701001218.3D316260@viggo.jf.intel.com> <5775F418.2000803@sr71.net> <874m89cu61.fsf@x220.int.ebiederm.org> <57769188.9060708@sr71.net> Date: Fri, 01 Jul 2016 13:12:55 -0500 In-Reply-To: <57769188.9060708@sr71.net> (Dave Hansen's message of "Fri, 1 Jul 2016 08:51:36 -0700") Message-ID: <878txlb520.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1bJ37o-0001CK-Iz;;;mid=<878txlb520.fsf@x220.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=67.3.204.119;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1/imSLN9UxcbH5QX/0TmP66VitSUzKciHo= X-SA-Exim-Connect-IP: 67.3.204.119 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Dave Hansen X-Spam-Relay-Country: X-Spam-Timing: total 1177 ms - load_scoreonly_sql: 0.10 (0.0%), signal_user_changed: 4.4 (0.4%), b_tie_ro: 3.1 (0.3%), parse: 1.17 (0.1%), extract_message_metadata: 18 (1.5%), get_uri_detail_list: 1.90 (0.2%), tests_pri_-1000: 7 (0.6%), tests_pri_-950: 1.28 (0.1%), tests_pri_-900: 1.07 (0.1%), tests_pri_-400: 23 (1.9%), check_bayes: 21 (1.8%), b_tokenize: 6 (0.6%), b_tok_get_all: 7 (0.6%), b_comp_prob: 2.3 (0.2%), b_tok_touch_all: 3.0 (0.3%), b_finish: 0.88 (0.1%), tests_pri_0: 229 (19.5%), check_dkim_signature: 0.55 (0.0%), check_dkim_adsp: 3.2 (0.3%), tests_pri_500: 890 (75.6%), poll_dns_idle: 860 (73.0%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH 6/6] x86: Fix stray A/D bit setting into non-present PTEs X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dave Hansen writes: > 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? Given that __pte_to_swp_entry on x86_64 is just __pte_val or pte.pte it does no filtering. Similarly __swp_type(arch_entry) is a >> and swp_entry(type, ...) is a << of what appears to be same amount for the swap type. So any corruption in the upper bits of the pte will be preserved as a swap type. In fact I strongly suspect that the compiler can optimize out all of the work done by "swp_entry(__swp_type(arch_entry), _swp_offset(arch_entry))". Eric