From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by kanga.kvack.org (Postfix) with ESMTP id 918DD6B0038 for ; Sun, 13 Dec 2015 03:44:31 -0500 (EST) Received: by pabur14 with SMTP id ur14so88100389pab.0 for ; Sun, 13 Dec 2015 00:44:31 -0800 (PST) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com. [119.145.14.65]) by mx.google.com with ESMTPS id y13si424139pfi.174.2015.12.13.00.44.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 13 Dec 2015 00:44:30 -0800 (PST) Message-ID: <566D2F23.4030302@huawei.com> Date: Sun, 13 Dec 2015 16:41:07 +0800 From: Xishi Qiu MIME-Version: 1.0 Subject: x86: a question about protection_map Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: LKML , Linux MM When we use mprotect to change the page prot, I find "__P001" and "__P011" are the same. So how we detect the write/read? pgprot_t protection_map[16] = { __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111, __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111 }; pgprot_t vm_get_page_prot(unsigned long vm_flags) { return __pgprot(pgprot_val(protection_map[vm_flags & (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) | pgprot_val(arch_vm_get_page_prot(vm_flags))); } #define __P001 PAGE_READONLY #define __P011 PAGE_COPY #define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \ _PAGE_ACCESSED | _PAGE_NX) #define PAGE_COPY PAGE_COPY_NOEXEC #define PAGE_READONLY __pgprot(_PAGE_PRESENT | _PAGE_USER | \ _PAGE_ACCESSED | _PAGE_NX) Thanks, Xishi Qiu -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org