linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Laura Abbott <labbott@redhat.com>
To: Tycho Andersen <tycho@docker.com>, linux-kernel@vger.kernel.org
Cc: linux-mm@kvack.org, kernel-hardening@lists.openwall.com,
	Marco Benatto <marco.antonio.780@gmail.com>,
	Juerg Haefliger <juerg.haefliger@canonical.com>,
	Juerg Haefliger <juerg.haefliger@hpe.com>
Subject: Re: [PATCH v5 02/10] mm, x86: Add support for eXclusive Page Frame Ownership (XPFO)
Date: Mon, 14 Aug 2017 15:30:00 -0700	[thread overview]
Message-ID: <910adbb5-c5d7-3091-1c92-996f73dd6221@redhat.com> (raw)
In-Reply-To: <20170809200755.11234-3-tycho@docker.com>

On 08/09/2017 01:07 PM, Tycho Andersen wrote:
> +/* Update a single kernel page table entry */
> +inline void set_kpte(void *kaddr, struct page *page, pgprot_t prot)
> +{
> +	unsigned int level;
> +	pgprot_t msk_clr;
> +	pte_t *pte = lookup_address((unsigned long)kaddr, &level);
> +
> +	BUG_ON(!pte);
> +
> +	switch (level) {
> +	case PG_LEVEL_4K:
> +		set_pte_atomic(pte, pfn_pte(page_to_pfn(page), canon_pgprot(prot)));
> +		break;
> +	case PG_LEVEL_2M:
> +		/* We need to check if it's a 2M page or 1GB page before retrieve
> +		 * pgprot info, as each one will be extracted from a different
> +		 * page table levels */
> +		msk_clr = pmd_pgprot(*(pmd_t*)pte);
> +	case PG_LEVEL_1G: {
> +		struct cpa_data cpa;
> +		int do_split;
> +
> +		msk_clr = pud_pgprot(*(pud_t*)pte);
> +
> +		memset(&cpa, 0, sizeof(cpa));
> +		cpa.vaddr = kaddr;
> +		cpa.pages = &page;
> +		cpa.mask_set = prot;
> +		cpa.mask_clr = msk_clr;
> +		cpa.numpages = 1;
> +		cpa.flags = 0;
> +		cpa.curpage = 0;
> +		cpa.force_split = 0;
> +
> +
> +		do_split = try_preserve_large_page(pte, (unsigned long)kaddr, &cpa);
> +		if (do_split) {
> +			spin_lock(&cpa_lock);
> +			BUG_ON(split_large_page(&cpa, pte, (unsigned long)kaddr));
> +			spin_unlock(&cpa_lock);
> +		}

This doesn't work in atomic contexts:

[   28.263571] BUG: sleeping function called from invalid context at 
mm/page_alloc.c:4048
[   28.263575] in_atomic(): 1, irqs_disabled(): 1, pid: 2433, name: 
gnome-terminal
[   28.263576] INFO: lockdep is turned off.
[   28.263578] irq event stamp: 0
[   28.263580] hardirqs last  enabled at (0): [<          (null)>] 
     (null)
[   28.263584] hardirqs last disabled at (0): [<ffffffff840af28a>] 
copy_process.part.25+0x62a/0x1e90
[   28.263587] softirqs last  enabled at (0): [<ffffffff840af28a>] 
copy_process.part.25+0x62a/0x1e90
[   28.263588] softirqs last disabled at (0): [<          (null)>] 
     (null)
[   28.263591] CPU: 0 PID: 2433 Comm: gnome-terminal Tainted: G        W 
       4.13.0-rc5-xpfo+ #86
[   28.263592] Hardware name: LENOVO 20BTS1N700/20BTS1N700, BIOS 
N14ET28W (1.06 ) 03/12/2015
[   28.263593] Call Trace:
[   28.263598]  dump_stack+0x8e/0xd6
[   28.263601]  ___might_sleep+0x164/0x250
[   28.263604]  __might_sleep+0x4a/0x80
[   28.263607]  __alloc_pages_nodemask+0x2b3/0x3e0
[   28.263611]  alloc_pages_current+0x6a/0xe0
[   28.263614]  split_large_page+0x4e/0x360
[   28.263618]  set_kpte+0x12c/0x150
[   28.263623]  xpfo_kunmap+0x7e/0xa0
[   28.263627]  wp_page_copy+0x16e/0x800
[   28.263631]  do_wp_page+0x9a/0x580
[   28.263633]  __handle_mm_fault+0xb1c/0x1130
[   28.263638]  handle_mm_fault+0x178/0x350
[   28.263641]  __do_page_fault+0x26e/0x510
[   28.263644]  do_page_fault+0x30/0x80
[   28.263647]  page_fault+0x28/0x30


split_large_page calls alloc_page with GFP_KERNEL. switching to
use GFP_ATOMIC in this path works locally for me.

Thanks,
Laura

> +
> +		break;
> +	}
> +	case PG_LEVEL_512G:
> +		/* fallthrough, splitting infrastructure doesn't
> +		 * support 512G pages. */
> +	default:
> +		BUG();
> +	}
> +
> +}

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2017-08-14 22:30 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-09 20:07 [PATCH v5 00/10] Add support for eXclusive Page Frame Ownership Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 01/10] mm: add MAP_HUGETLB support to vm_mmap Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 02/10] mm, x86: Add support for eXclusive Page Frame Ownership (XPFO) Tycho Andersen
2017-08-14 18:51   ` Laura Abbott
2017-08-14 22:30   ` Laura Abbott [this message]
2017-08-15  3:47     ` Tycho Andersen
2017-08-15  3:51       ` Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 03/10] swiotlb: Map the buffer if it was unmapped by XPFO Tycho Andersen
2017-08-10 13:01   ` Konrad Rzeszutek Wilk
2017-08-10 16:22     ` Tycho Andersen
2017-09-20 16:19   ` Dave Hansen
2017-09-20 22:47     ` Tycho Andersen
2017-09-20 23:25       ` Dave Hansen
2017-08-09 20:07 ` [PATCH v5 04/10] arm64: Add __flush_tlb_one() Tycho Andersen
2017-08-12 11:26   ` [kernel-hardening] " Mark Rutland
2017-08-14 16:35     ` Tycho Andersen
2017-08-14 16:50       ` Mark Rutland
2017-08-14 17:01         ` Tycho Andersen
2017-08-23 16:58         ` Tycho Andersen
2017-08-23 17:04           ` Mark Rutland
2017-08-23 17:13             ` Tycho Andersen
2017-08-24 15:45               ` Mark Rutland
2017-08-29 17:24                 ` Tycho Andersen
2017-08-30  5:31             ` Juerg Haefliger
2017-08-30 16:47               ` Tycho Andersen
2017-08-31  9:43                 ` Juerg Haefliger
2017-08-31  9:47                   ` Mark Rutland
2017-08-31 21:21                     ` Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 05/10] arm64/mm: Add support for XPFO Tycho Andersen
2017-08-11 18:01   ` [kernel-hardening] " Laura Abbott
2017-08-11 20:19     ` Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 06/10] arm64/mm: Disable section mappings if XPFO is enabled Tycho Andersen
2017-08-11 17:25   ` [kernel-hardening] " Laura Abbott
2017-08-11 21:13     ` Tycho Andersen
2017-08-11 21:52       ` Tycho Andersen
2017-08-12 11:17       ` Mark Rutland
2017-08-14 16:22         ` Tycho Andersen
2017-08-14 18:42           ` Laura Abbott
2017-08-14 20:28             ` Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 07/10] arm64/mm: Don't flush the data cache if the page is unmapped by XPFO Tycho Andersen
2017-08-12 11:57   ` [kernel-hardening] " Mark Rutland
2017-08-14 16:54     ` Mark Rutland
2017-08-14 20:27     ` Tycho Andersen
2017-08-15  9:39       ` Mark Rutland
2017-08-09 20:07 ` [PATCH v5 08/10] arm64/mm: Add support for XPFO to swiotlb Tycho Andersen
2017-08-10 13:11   ` Konrad Rzeszutek Wilk
2017-08-10 16:35     ` Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 09/10] mm: add a user_virt_to_phys symbol Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 10/10] lkdtm: Add test for XPFO Tycho Andersen
2017-08-12 20:24   ` kbuild test robot
2017-08-14 16:21     ` Tycho Andersen
2017-08-12 21:05   ` kbuild test robot
2017-08-14 19:10   ` Kees Cook
2017-08-14 20:29     ` Tycho Andersen
2017-08-11 23:35 ` [kernel-hardening] [PATCH v5 00/10] Add support for eXclusive Page Frame Ownership Laura Abbott

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=910adbb5-c5d7-3091-1c92-996f73dd6221@redhat.com \
    --to=labbott@redhat.com \
    --cc=juerg.haefliger@canonical.com \
    --cc=juerg.haefliger@hpe.com \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=marco.antonio.780@gmail.com \
    --cc=tycho@docker.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox