LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [RFC patch 2/5] ASoC: tlv320aic31xx: Add support for pll_r coefficient
From: Mark Brown @ 2021-11-22 14:33 UTC (permalink / raw)
  To: Michael Nazzareno Trimarchi
  Cc: bkylerussell, lgirdwood, Ariel D'Alessandro,
	kuninori.morimoto.gx, Xiubo.Lee, festevam, shengjiu.wang, tiwai,
	alsa-devel, linux-kernel, nicoleotsuka, perex, linuxppc-dev
In-Reply-To: <CAOf5uwnrUdF4fOVGvp8GmuUL6SpsyjPq46WBP7hcY7bYbw7RHA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 948 bytes --]

On Mon, Nov 22, 2021 at 03:24:42PM +0100, Michael Nazzareno Trimarchi wrote:
> On Mon, Nov 22, 2021 at 3:22 PM Mark Brown <broonie@kernel.org> wrote:
> > On Fri, Nov 19, 2021 at 12:32:45PM -0300, Ariel D'Alessandro wrote:

> > > When the clock used by the codec is BCLK, the operation parameters need
> > > to be calculated from input sample rate and format. Low frequency rates
> > > required different r multipliers, in order to achieve a higher PLL
> > > output frequency.

> > > Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
> > > Signed-off-by: Ariel D'Alessandro <ariel.dalessandro@collabora.com>

> > Did Michael write this code (in which case there should be a From: from
> > him) or did he work on the code with you?  The signoffs are a little
> > confusing.

> It's fine. We are working together

In such situations it's best to include a Co-developed-by tag to say
what's going on, that makes it clear what's going on.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply

* Re: [PATCH 1/8] powerpc/mm: Make slice specific to book3s/64
From: kernel test robot @ 2021-11-22 14:48 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, alex
  Cc: linux-mm, kbuild-all, linuxppc-dev, linux-kernel
In-Reply-To: <14e2c0b0d4fff49c1cb30166f54ce8e445e17b16.1637570556.git.christophe.leroy@csgroup.eu>

[-- Attachment #1: Type: text/plain, Size: 25236 bytes --]

Hi Christophe,

I love your patch! Perhaps something to improve:

[auto build test WARNING on powerpc/next]
[also build test WARNING on hnaz-mm/master linus/master v5.16-rc2 next-20211118]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Christophe-Leroy/Convert-powerpc-to-default-topdown-mmap-layout/20211122-165115
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc64-randconfig-s031-20211122 (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 11.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://github.com/0day-ci/linux/commit/1d0b7cc86d08f25f595b52d8c39ba9ca1d29a30a
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Christophe-Leroy/Convert-powerpc-to-default-topdown-mmap-layout/20211122-165115
        git checkout 1d0b7cc86d08f25f595b52d8c39ba9ca1d29a30a
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=powerpc64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   arch/powerpc/mm/book3s64/slice.c: In function 'slice_get_unmapped_area':
>> arch/powerpc/mm/book3s64/slice.c:639:1: warning: the frame size of 1040 bytes is larger than 1024 bytes [-Wframe-larger-than=]
     639 | }
         | ^


vim +639 arch/powerpc/mm/book3s64/slice.c

3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  428  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  429  unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  430  				      unsigned long flags, unsigned int psize,
34d07177b802e9 arch/powerpc/mm/slice.c Michel Lespinasse      2013-04-29  431  				      int topdown)
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  432  {
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  433  	struct slice_mask good_mask;
f3207c124e7aa8 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-03-22  434  	struct slice_mask potential_mask;
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  435  	const struct slice_mask *maskp;
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  436  	const struct slice_mask *compat_maskp = NULL;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  437  	int fixed = (flags & MAP_FIXED);
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  438  	int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT);
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  439  	unsigned long page_size = 1UL << pshift;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  440  	struct mm_struct *mm = current->mm;
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  441  	unsigned long newaddr;
f4ea6dcb08ea2c arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-03-30  442  	unsigned long high_limit;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  443  
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  444  	high_limit = DEFAULT_MAP_WINDOW;
35602f82d0c765 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  445  	if (addr >= high_limit || (fixed && (addr + len > high_limit)))
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  446  		high_limit = TASK_SIZE;
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  447  
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  448  	if (len > high_limit)
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  449  		return -ENOMEM;
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  450  	if (len & (page_size - 1))
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  451  		return -EINVAL;
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  452  	if (fixed) {
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  453  		if (addr & (page_size - 1))
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  454  			return -EINVAL;
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  455  		if (addr > high_limit - len)
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  456  			return -ENOMEM;
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  457  	}
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  458  
60458fba469a69 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2019-04-17  459  	if (high_limit > mm_ctx_slb_addr_limit(&mm->context)) {
5709f7cfd83052 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  460  		/*
5709f7cfd83052 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  461  		 * Increasing the slb_addr_limit does not require
5709f7cfd83052 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  462  		 * slice mask cache to be recalculated because it should
5709f7cfd83052 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  463  		 * be already initialised beyond the old address limit.
5709f7cfd83052 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  464  		 */
60458fba469a69 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2019-04-17  465  		mm_ctx_set_slb_addr_limit(&mm->context, high_limit);
54be0b9c7c9888 arch/powerpc/mm/slice.c Michael Ellerman       2018-10-02  466  
54be0b9c7c9888 arch/powerpc/mm/slice.c Michael Ellerman       2018-10-02  467  		on_each_cpu(slice_flush_segments, mm, 1);
f4ea6dcb08ea2c arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-03-30  468  	}
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  469  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  470  	/* Sanity checks */
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  471  	BUG_ON(mm->task_size == 0);
60458fba469a69 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2019-04-17  472  	BUG_ON(mm_ctx_slb_addr_limit(&mm->context) == 0);
764041e0f43cc7 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2016-04-29  473  	VM_BUG_ON(radix_enabled());
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  474  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  475  	slice_dbg("slice_get_unmapped_area(mm=%p, psize=%d...\n", mm, psize);
34d07177b802e9 arch/powerpc/mm/slice.c Michel Lespinasse      2013-04-29  476  	slice_dbg(" addr=%lx, len=%lx, flags=%lx, topdown=%d\n",
34d07177b802e9 arch/powerpc/mm/slice.c Michel Lespinasse      2013-04-29  477  		  addr, len, flags, topdown);
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  478  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  479  	/* If hint, make sure it matches our alignment restrictions */
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  480  	if (!fixed && addr) {
b711531641038f arch/powerpc/mm/slice.c Christophe Leroy       2020-04-20  481  		addr = ALIGN(addr, page_size);
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  482  		slice_dbg(" aligned addr=%lx\n", addr);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  483  		/* Ignore hint if it's too large or overlaps a VMA */
3b4d07d2674f6b arch/powerpc/mm/slice.c Aneesh Kumar K.V       2019-02-26  484  		if (addr > high_limit - len || addr < mmap_min_addr ||
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  485  		    !slice_area_is_free(mm, addr, len))
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  486  			addr = 0;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  487  	}
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  488  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  489  	/* First make up a "good" mask of slices that have the right size
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  490  	 * already
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  491  	 */
6f60cc98df2be7 arch/powerpc/mm/slice.c Christophe Leroy       2019-04-25  492  	maskp = slice_mask_for_size(&mm->context, psize);
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  493  
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  494  	/*
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  495  	 * Here "good" means slices that are already the right page size,
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  496  	 * "compat" means slices that have a compatible page size (i.e.
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  497  	 * 4k in a 64k pagesize kernel), and "free" means slices without
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  498  	 * any VMAs.
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  499  	 *
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  500  	 * If MAP_FIXED:
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  501  	 *	check if fits in good | compat => OK
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  502  	 *	check if fits in good | compat | free => convert free
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  503  	 *	else bad
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  504  	 * If have hint:
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  505  	 *	check if hint fits in good => OK
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  506  	 *	check if hint fits in good | free => convert free
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  507  	 * Otherwise:
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  508  	 *	search in good, found => OK
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  509  	 *	search in good | free, found => convert free
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  510  	 *	search in good | compat | free, found => convert free.
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  511  	 */
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  512  
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  513  	/*
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  514  	 * If we support combo pages, we can allow 64k pages in 4k slices
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  515  	 * The mask copies could be avoided in most cases here if we had
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  516  	 * a pointer to good mask for the next code to use.
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  517  	 */
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  518  	if (IS_ENABLED(CONFIG_PPC_64K_PAGES) && psize == MMU_PAGE_64K) {
6f60cc98df2be7 arch/powerpc/mm/slice.c Christophe Leroy       2019-04-25  519  		compat_maskp = slice_mask_for_size(&mm->context, MMU_PAGE_4K);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  520  		if (fixed)
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  521  			slice_or_mask(&good_mask, maskp, compat_maskp);
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  522  		else
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  523  			slice_copy_mask(&good_mask, maskp);
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  524  	} else {
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  525  		slice_copy_mask(&good_mask, maskp);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  526  	}
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  527  
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  528  	slice_print_mask(" good_mask", &good_mask);
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  529  	if (compat_maskp)
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  530  		slice_print_mask(" compat_mask", compat_maskp);
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  531  
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  532  	/* First check hint if it's valid or if we have MAP_FIXED */
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  533  	if (addr != 0 || fixed) {
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  534  		/* Check if we fit in the good mask. If we do, we just return,
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  535  		 * nothing else to do
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  536  		 */
ae3066bd1cbe58 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  537  		if (slice_check_range_fits(mm, &good_mask, addr, len)) {
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  538  			slice_dbg(" fits good !\n");
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  539  			newaddr = addr;
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  540  			goto return_addr;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  541  		}
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  542  	} else {
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  543  		/* Now let's see if we can find something in the existing
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  544  		 * slices for that size
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  545  		 */
830fd2d45aa116 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  546  		newaddr = slice_find_area(mm, len, &good_mask,
f4ea6dcb08ea2c arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-03-30  547  					  psize, topdown, high_limit);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  548  		if (newaddr != -ENOMEM) {
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  549  			/* Found within the good mask, we don't have to setup,
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  550  			 * we thus return directly
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  551  			 */
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  552  			slice_dbg(" found area at 0x%lx\n", newaddr);
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  553  			goto return_addr;
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  554  		}
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  555  	}
7a06c66835f75f arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-11-10  556  	/*
7a06c66835f75f arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-11-10  557  	 * We don't fit in the good mask, check what other slices are
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  558  	 * empty and thus can be converted
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  559  	 */
7a06c66835f75f arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-11-10  560  	slice_mask_for_free(mm, &potential_mask, high_limit);
b8c93549142077 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  561  	slice_or_mask(&potential_mask, &potential_mask, &good_mask);
830fd2d45aa116 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  562  	slice_print_mask(" potential", &potential_mask);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  563  
ae3066bd1cbe58 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  564  	if (addr != 0 || fixed) {
ae3066bd1cbe58 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  565  		if (slice_check_range_fits(mm, &potential_mask, addr, len)) {
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  566  			slice_dbg(" fits potential !\n");
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  567  			newaddr = addr;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  568  			goto convert;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  569  		}
ae3066bd1cbe58 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  570  	}
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  571  
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  572  	/* If we have MAP_FIXED and failed the above steps, then error out */
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  573  	if (fixed)
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  574  		return -EBUSY;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  575  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  576  	slice_dbg(" search...\n");
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  577  
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  578  	/* If we had a hint that didn't work out, see if we can fit
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  579  	 * anywhere in the good area.
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  580  	 */
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  581  	if (addr) {
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  582  		newaddr = slice_find_area(mm, len, &good_mask,
f4ea6dcb08ea2c arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-03-30  583  					  psize, topdown, high_limit);
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  584  		if (newaddr != -ENOMEM) {
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  585  			slice_dbg(" found area at 0x%lx\n", newaddr);
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  586  			goto return_addr;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  587  		}
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  588  	}
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  589  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  590  	/* Now let's see if we can find something in the existing slices
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  591  	 * for that size plus free slices
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  592  	 */
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  593  	newaddr = slice_find_area(mm, len, &potential_mask,
f4ea6dcb08ea2c arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-03-30  594  				  psize, topdown, high_limit);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  595  
203a1fa6286671 arch/powerpc/mm/slice.c Christophe Leroy       2019-04-25  596  	if (IS_ENABLED(CONFIG_PPC_64K_PAGES) && newaddr == -ENOMEM &&
203a1fa6286671 arch/powerpc/mm/slice.c Christophe Leroy       2019-04-25  597  	    psize == MMU_PAGE_64K) {
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  598  		/* retry the search with 4k-page slices included */
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  599  		slice_or_mask(&potential_mask, &potential_mask, compat_maskp);
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  600  		newaddr = slice_find_area(mm, len, &potential_mask,
f4ea6dcb08ea2c arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-03-30  601  					  psize, topdown, high_limit);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  602  	}
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  603  
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  604  	if (newaddr == -ENOMEM)
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  605  		return -ENOMEM;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  606  
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  607  	slice_range_to_mask(newaddr, len, &potential_mask);
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  608  	slice_dbg(" found potential area at 0x%lx\n", newaddr);
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  609  	slice_print_mask(" mask", &potential_mask);
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  610  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  611   convert:
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  612  	/*
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  613  	 * Try to allocate the context before we do slice convert
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  614  	 * so that we handle the context allocation failure gracefully.
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  615  	 */
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  616  	if (need_extra_context(mm, newaddr)) {
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  617  		if (alloc_extended_context(mm, newaddr) < 0)
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  618  			return -ENOMEM;
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  619  	}
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  620  
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  621  	slice_andnot_mask(&potential_mask, &potential_mask, &good_mask);
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  622  	if (compat_maskp && !fixed)
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  623  		slice_andnot_mask(&potential_mask, &potential_mask, compat_maskp);
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  624  	if (potential_mask.low_slices ||
db3a528db41caa arch/powerpc/mm/slice.c Christophe Leroy       2018-02-22  625  		(SLICE_NUM_HIGH &&
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  626  		 !bitmap_empty(potential_mask.high_slices, SLICE_NUM_HIGH))) {
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  627  		slice_convert(mm, &potential_mask, psize);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  628  		if (psize > MMU_PAGE_BASE)
54be0b9c7c9888 arch/powerpc/mm/slice.c Michael Ellerman       2018-10-02  629  			on_each_cpu(slice_flush_segments, mm, 1);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  630  	}
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  631  	return newaddr;
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  632  
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  633  return_addr:
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  634  	if (need_extra_context(mm, newaddr)) {
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  635  		if (alloc_extended_context(mm, newaddr) < 0)
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  636  			return -ENOMEM;
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  637  	}
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  638  	return newaddr;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08 @639  }
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  640  EXPORT_SYMBOL_GPL(slice_get_unmapped_area);
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  641  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33024 bytes --]

^ permalink raw reply

* [powerpc:merge] BUILD SUCCESS 95c6ab13ec7e63e5e8628e237082431779d270f3
From: kernel test robot @ 2021-11-22 15:46 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev

tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git merge
branch HEAD: 95c6ab13ec7e63e5e8628e237082431779d270f3  Automatic merge of 'master' into merge (2021-11-22 10:52)

elapsed time: 921m

configs tested: 137
configs skipped: 3

The following configs have been built successfully.
More configs may be tested in the coming days.

gcc tested configs:
arm64                               defconfig
arm64                            allyesconfig
arm                              allmodconfig
arm                              allyesconfig
arm                                 defconfig
i386                 randconfig-c001-20211122
mips                 randconfig-c004-20211122
m68k                       m5208evb_defconfig
arm                            pleb_defconfig
xtensa                  nommu_kc705_defconfig
parisc                           alldefconfig
arm                            qcom_defconfig
arc                      axs103_smp_defconfig
m68k                          sun3x_defconfig
mips                           ci20_defconfig
openrisc                         alldefconfig
sh                          kfr2r09_defconfig
mips                           mtx1_defconfig
ia64                          tiger_defconfig
arm                          iop32x_defconfig
sh                     magicpanelr2_defconfig
powerpc                 mpc8540_ads_defconfig
arc                            hsdk_defconfig
m68k                         amcore_defconfig
alpha                               defconfig
arm                        neponset_defconfig
sh                            hp6xx_defconfig
arm                         at91_dt_defconfig
mips                 decstation_r4k_defconfig
sh                      rts7751r2d1_defconfig
powerpc                   motionpro_defconfig
sh                         microdev_defconfig
powerpc                   microwatt_defconfig
arm                          collie_defconfig
sh                           se7721_defconfig
powerpc                     tqm5200_defconfig
powerpc                      pasemi_defconfig
powerpc                     ep8248e_defconfig
m68k                       bvme6000_defconfig
arm                     am200epdkit_defconfig
nios2                               defconfig
mips                           ip28_defconfig
arm                             rpc_defconfig
mips                            e55_defconfig
i386                             allyesconfig
powerpc                    ge_imp3a_defconfig
sh                         ap325rxa_defconfig
openrisc                  or1klitex_defconfig
arm                            xcep_defconfig
x86_64                              defconfig
arm                      pxa255-idp_defconfig
arm                         mv78xx0_defconfig
powerpc                     tqm8540_defconfig
microblaze                          defconfig
m68k                         apollo_defconfig
arm                       aspeed_g5_defconfig
sh                            migor_defconfig
microblaze                      mmu_defconfig
mips                malta_qemu_32r6_defconfig
arm                  randconfig-c002-20211122
ia64                             allmodconfig
ia64                                defconfig
ia64                             allyesconfig
m68k                                defconfig
m68k                             allyesconfig
m68k                             allmodconfig
arc                              allyesconfig
nds32                             allnoconfig
csky                                defconfig
alpha                            allyesconfig
nds32                               defconfig
nios2                            allyesconfig
arc                                 defconfig
sh                               allmodconfig
h8300                            allyesconfig
xtensa                           allyesconfig
parisc                              defconfig
s390                             allyesconfig
s390                             allmodconfig
parisc                           allyesconfig
s390                                defconfig
i386                                defconfig
i386                              debian-10.3
sparc                            allyesconfig
sparc                               defconfig
mips                             allmodconfig
mips                             allyesconfig
powerpc                           allnoconfig
powerpc                          allmodconfig
powerpc                          allyesconfig
x86_64               randconfig-a015-20211122
x86_64               randconfig-a016-20211122
i386                 randconfig-a015-20211122
i386                 randconfig-a012-20211122
i386                 randconfig-a013-20211122
i386                 randconfig-a014-20211122
i386                 randconfig-a011-20211122
i386                 randconfig-a016-20211122
x86_64               randconfig-a001-20211121
x86_64               randconfig-a003-20211121
x86_64               randconfig-a004-20211121
x86_64               randconfig-a005-20211121
x86_64               randconfig-a002-20211121
x86_64               randconfig-a006-20211121
arc                  randconfig-r043-20211122
s390                 randconfig-r044-20211122
riscv                randconfig-r042-20211122
riscv                    nommu_k210_defconfig
riscv                            allyesconfig
riscv                    nommu_virt_defconfig
riscv                             allnoconfig
riscv                               defconfig
riscv                          rv32_defconfig
riscv                            allmodconfig
um                           x86_64_defconfig
um                             i386_defconfig
x86_64                           allyesconfig
x86_64                    rhel-8.3-kselftests
x86_64                               rhel-8.3
x86_64                          rhel-8.3-func
x86_64                                  kexec

clang tested configs:
s390                 randconfig-c005-20211122
riscv                randconfig-c006-20211122
i386                 randconfig-c001-20211122
powerpc              randconfig-c003-20211122
arm                  randconfig-c002-20211122
x86_64               randconfig-c007-20211122
mips                 randconfig-c004-20211122
x86_64               randconfig-a001-20211122
x86_64               randconfig-a003-20211122
x86_64               randconfig-a004-20211122
x86_64               randconfig-a002-20211122
x86_64               randconfig-a005-20211122
x86_64               randconfig-a006-20211122
i386                 randconfig-a001-20211122
i386                 randconfig-a002-20211122
i386                 randconfig-a005-20211122
i386                 randconfig-a006-20211122
i386                 randconfig-a004-20211122
i386                 randconfig-a003-20211122

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

^ permalink raw reply

* Re: [PATCH v2 2/5] preempt/dynamic: Introduce preempt mode accessors
From: Valentin Schneider @ 2021-11-22 16:37 UTC (permalink / raw)
  To: Christophe Leroy, linux-kernel, kasan-dev, linuxppc-dev,
	linux-kbuild
  Cc: Marco Elver, Michal Marek, Peter Zijlstra, Frederic Weisbecker,
	Mike Galbraith, Nick Desaulniers, Steven Rostedt, Ingo Molnar,
	Paul Mackerras, Masahiro Yamada, Dmitry Vyukov
In-Reply-To: <2f22c57d-9bf0-3cc1-f0f1-61ecdf5dfa52@csgroup.eu>

On 16/11/21 14:29, Christophe Leroy wrote:
> Le 10/11/2021 à 21:24, Valentin Schneider a écrit :
>> CONFIG_PREEMPT{_NONE, _VOLUNTARY} designate either:
>> o The build-time preemption model when !PREEMPT_DYNAMIC
>> o The default boot-time preemption model when PREEMPT_DYNAMIC
>>
>> IOW, using those on PREEMPT_DYNAMIC kernels is meaningless - the actual
>> model could have been set to something else by the "preempt=foo" cmdline
>> parameter.
>>
>> Introduce a set of helpers to determine the actual preemption mode used by
>> the live kernel.
>>
>> Suggested-by: Marco Elver <elver@google.com>
>> Signed-off-by: Valentin Schneider <valentin.schneider@arm.com>
>> ---
>>   include/linux/sched.h | 16 ++++++++++++++++
>>   kernel/sched/core.c   | 11 +++++++++++
>>   2 files changed, 27 insertions(+)
>>
>> diff --git a/include/linux/sched.h b/include/linux/sched.h
>> index 5f8db54226af..0640d5622496 100644
>> --- a/include/linux/sched.h
>> +++ b/include/linux/sched.h
>> @@ -2073,6 +2073,22 @@ static inline void cond_resched_rcu(void)
>>   #endif
>>   }
>>
>> +#ifdef CONFIG_PREEMPT_DYNAMIC
>> +
>> +extern bool is_preempt_none(void);
>> +extern bool is_preempt_voluntary(void);
>> +extern bool is_preempt_full(void);
>
> Those are trivial tests supposed to be used in fast pathes. They should
> be static inlines in order to minimise the overhead.
>
>> +
>> +#else
>> +
>> +#define is_preempt_none() IS_ENABLED(CONFIG_PREEMPT_NONE)
>> +#define is_preempt_voluntary() IS_ENABLED(CONFIG_PREEMPT_VOLUNTARY)
>> +#define is_preempt_full() IS_ENABLED(CONFIG_PREEMPT)
>
> Would be better to use static inlines here as well instead of macros.
>

I realize I stripped all ppc folks from the cclist after dropping the ppc
snippet, but you guys might still be interested - my bad. That's done in
v3:

https://lore.kernel.org/lkml/20211112185203.280040-1-valentin.schneider@arm.com/

>> +
>> +#endif
>> +
>> +#define is_preempt_rt() IS_ENABLED(CONFIG_PREEMPT_RT)
>> +
>>   /*
>>    * Does a critical section need to be broken due to another
>>    * task waiting?: (technically does not depend on CONFIG_PREEMPTION,
>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>> index 97047aa7b6c2..9db7f77e53c3 100644
>> --- a/kernel/sched/core.c
>> +++ b/kernel/sched/core.c
>> @@ -6638,6 +6638,17 @@ static void __init preempt_dynamic_init(void)
>>      }
>>   }
>>
>> +#define PREEMPT_MODE_ACCESSOR(mode) \
>> +	bool is_preempt_##mode(void)						 \
>> +	{									 \
>> +		WARN_ON_ONCE(preempt_dynamic_mode == preempt_dynamic_undefined); \
>
> Not sure using WARN_ON is a good idea here, as it may be called very
> early, see comment on powerpc patch.

Bah, I was gonna say that you *don't* want users of is_preempt_*() to be
called before the "final" preemption model is set up (such users would need
to make use of static_calls), but I realize there's a debug interface to
flip the preemption model at will... Say an initcall sees
is_preempt_voluntary() and sets things up accordingly, and then the debug
knob switches to preempt_full. I don't think there's much we can really do
here though :/

>
>> +		return preempt_dynamic_mode == preempt_dynamic_##mode;		 \
>> +	}
>
> I'm not sure that's worth a macro. You only have 3 accessors, 2 lines of
> code each. Just define all 3 in plain text.
>
> CONFIG_PREEMPT_DYNAMIC is based on using strategies like static_calls in
> order to minimise the overhead. For those accessors you should use the
> same kind of approach and use things like jump_labels in order to not
> redo the test at each time and minimise overhead as much as possible.
>

That's a valid point, though the few paths that need patching up and don't
make use of static calls already (AFAICT the ppc irq path I was touching in
v2 needs to make use of irqentry_exit_cond_resched()) really seem like
slow-paths.

>> +
>> +PREEMPT_MODE_ACCESSOR(none)
>> +PREEMPT_MODE_ACCESSOR(voluntary)
>> +PREEMPT_MODE_ACCESSOR(full)
>> +
>>   #else /* !CONFIG_PREEMPT_DYNAMIC */
>>
>>   static inline void preempt_dynamic_init(void) { }
>>

^ permalink raw reply

* Re: [PATCH v2 3/5] powerpc: Use preemption model accessors
From: Valentin Schneider @ 2021-11-22 16:44 UTC (permalink / raw)
  To: Christophe Leroy, linux-kernel, kasan-dev, linuxppc-dev,
	linux-kbuild
  Cc: Marco Elver, Michal Marek, Peter Zijlstra, Frederic Weisbecker,
	Mike Galbraith, Nick Desaulniers, Steven Rostedt, Ingo Molnar,
	Paul Mackerras, Masahiro Yamada, Dmitry Vyukov
In-Reply-To: <431fb6da-fe21-c5a6-bfb3-4e26bdc153b4@csgroup.eu>

On 16/11/21 14:41, Christophe Leroy wrote:
> Le 10/11/2021 à 21:24, Valentin Schneider a écrit :
>> Per PREEMPT_DYNAMIC, checking CONFIG_PREEMPT doesn't tell you the actual
>> preemption model of the live kernel. Use the newly-introduced accessors
>> instead.
>
> Is that change worth it for now ? As far as I can see powerpc doesn't
> have DYNAMIC PREEMPT, a lot of work needs to be done before being able
> to use it:
> - Implement GENERIC_ENTRY
> - Implement STATIC_CALLS (already done on PPC32, to be done on PPC64)
>

You're right, I ditched this patch for v3 - AFAICT the change wasn't even
valid as the preempt_schedule_irq() call needs to be replaced with
irqentry_exit_cond_resched() (IOW this needs to make use of the generic
entry code).

>>
>> sched_init() -> preempt_dynamic_init() happens way before IRQs are set up,
>> so this should be fine.
>
> It looks like you are mixing up interrupts and IRQs (also known as
> "external interrupts").
>
> ISI (Instruction Storage Interrupt) and DSI (Data Storage Interrupt) for
> instance are also interrupts. They happen everytime there is a page
> fault so may happen pretty early.
>
> Traps generated by WARN_ON() are also interrupts that may happen at any
> time.
>

Michael pointed this out and indeed triggering a WARN_ON() there is not
super smart. Thanks for teaching me a bit of what I'm putting my grubby
hands in :)

^ permalink raw reply

* Re: [PATCH v1] KVM: PPC: Book3S HV: Prevent POWER7/8 TLB flush flushing SLB
From: Fabiano Rosas @ 2021-11-22 18:34 UTC (permalink / raw)
  To: Nicholas Piggin, linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20211119031627.577853-1-npiggin@gmail.com>

Nicholas Piggin <npiggin@gmail.com> writes:

> The POWER9 ERAT flush instruction is a SLBIA with IH=7, which is a
> reserved value on POWER7/8. On POWER8 this invalidates the SLB entries
> above index 0, similarly to SLBIA IH=0.
>
> If the SLB entries are invalidated, and then the guest is bypassed, the
> host SLB does not get re-loaded, so the bolted entries above 0 will be
> lost. This can result in kernel stack access causing a SLB fault.
>
> Kernel stack access causing a SLB fault was responsible for the infamous
> mega bug (search "Fix SLB reload bug"). Although since commit
> 48e7b7695745 ("powerpc/64s/hash: Convert SLB miss handlers to C") that
> starts using the kernel stack in the SLB miss handler, it might only
> result in an infinite loop of SLB faults. In any case it's a bug.
>
> Fix this by only executing the instruction on >= POWER9 where IH=7 is
> defined not to invalidate the SLB. POWER7/8 don't require this ERAT
> flush.
>
> Fixes: 5008711259201 ("KVM: PPC: Book3S HV: Invalidate ERAT when flushing guest TLB entries")
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>

Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>

> ---
>  arch/powerpc/kvm/book3s_hv_builtin.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kvm/book3s_hv_builtin.c b/arch/powerpc/kvm/book3s_hv_builtin.c
> index fcf4760a3a0e..70b7a8f97153 100644
> --- a/arch/powerpc/kvm/book3s_hv_builtin.c
> +++ b/arch/powerpc/kvm/book3s_hv_builtin.c
> @@ -695,6 +695,7 @@ static void flush_guest_tlb(struct kvm *kvm)
>  				       "r" (0) : "memory");
>  		}
>  		asm volatile("ptesync": : :"memory");
> +		// POWER9 congruence-class TLBIEL leaves ERAT. Flush it now.
>  		asm volatile(PPC_RADIX_INVALIDATE_ERAT_GUEST : : :"memory");
>  	} else {
>  		for (set = 0; set < kvm->arch.tlb_sets; ++set) {
> @@ -705,7 +706,9 @@ static void flush_guest_tlb(struct kvm *kvm)
>  			rb += PPC_BIT(51);	/* increment set number */
>  		}
>  		asm volatile("ptesync": : :"memory");
> -		asm volatile(PPC_ISA_3_0_INVALIDATE_ERAT : : :"memory");
> +		// POWER9 congruence-class TLBIEL leaves ERAT. Flush it now.
> +		if (cpu_has_feature(CPU_FTR_ARCH_300))
> +			asm volatile(PPC_ISA_3_0_INVALIDATE_ERAT : : :"memory");
>  	}
>  }

^ permalink raw reply

* Re: [PATCH] powerpc/signal32: Use struct_group() to zero spe regs
From: Kees Cook @ 2021-11-22 20:47 UTC (permalink / raw)
  To: Michael Ellerman
  Cc: Aneesh Kumar K.V, kernel test robot, Peter Zijlstra,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org,
	Paul Mackerras, Nicholas Piggin, Sudeep Holla,
	linuxppc-dev@lists.ozlabs.org, Eric W. Biederman
In-Reply-To: <87ilwkrbhz.fsf@mpe.ellerman.id.au>

On Mon, Nov 22, 2021 at 04:43:36PM +1100, Michael Ellerman wrote:
> LEROY Christophe <christophe.leroy@csgroup.eu> writes:
> > Le 18/11/2021 à 21:36, Kees Cook a écrit :
> >> In preparation for FORTIFY_SOURCE performing compile-time and run-time
> >> field bounds checking for memset(), avoid intentionally writing across
> >> neighboring fields.
> >> 
> >> Add a struct_group() for the spe registers so that memset() can correctly reason
> >> about the size:
> >> 
> >>     In function 'fortify_memset_chk',
> >>         inlined from 'restore_user_regs.part.0' at arch/powerpc/kernel/signal_32.c:539:3:
> >>     >> include/linux/fortify-string.h:195:4: error: call to '__write_overflow_field' declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
> >>       195 |    __write_overflow_field();
> >>           |    ^~~~~~~~~~~~~~~~~~~~~~~~
> >> 
> >> Reported-by: kernel test robot <lkp@intel.com>
> >> Signed-off-by: Kees Cook <keescook@chromium.org>
> >
> > Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> 
> Acked-by: Michael Ellerman <mpe@ellerman.id.au>

Thanks! Should I take this via my tree, or do you want to take it via
ppc?

-Kees

-- 
Kees Cook

^ permalink raw reply

* Re: [PATCH 0/2] of: remove reserved regions count restriction
From: Mike Rapoport @ 2021-11-21  6:43 UTC (permalink / raw)
  To: Calvin Zhang
  Cc: Kirill A. Shutemov, Mark Rutland, Kefeng Wang, Rich Felker,
	Jinyang He, David Hildenbrand, Lee Jones, linux-kernel,
	Max Filippov, Anup Patel, Guo Ren, Guo Ren, linux-csky,
	Nick Kossifidis, Vladimir Isaev, Tiezhu Yang, Vincent Chen,
	Will Deacon, Markus Elfring, Vitaly Wool, Jonas Bonn, devicetree,
	linux-snps-arc, uclinux-h8-devel, Yoshinori Sato, Palmer Dabbelt,
	linux-sh, Rafael J. Wysocki, Russell King, Ley Foon Tan,
	Geert Uytterhoeven, Aneesh Kumar K.V, Catalin Marinas,
	Ganesh Goudar, David Brazdil, linux-riscv, Guenter Roeck,
	Alexander Sverdlin, Thierry Reding, Albert Ou, Arnd Bergmann,
	Anshuman Khandual, linux-xtensa, Vineet Gupta, Andreas Oetken,
	Stefan Kristiansson, Russell King (Oracle), Rob Herring,
	Christophe JAILLET, Greentime Hu, Paul Walmsley, Stafford Horne,
	Andy Shevchenko, linux-arm-kernel, Andrey Konovalov,
	Christophe Leroy, Chris Zankel, Thomas Bogendoerfer, linux-mips,
	Alexandre Ghiti, Nick Hu, Atish Patra, Greg Kroah-Hartman,
	Randy Dunlap, Frank Rowand, Serge Semin, Dinh Nguyen,
	Zhang Yunkai, Palmer Dabbelt, Souptick Joarder, Marc Zyngier,
	Mauri Sandberg, Paul Mackerras, Andrew Morton, linuxppc-dev,
	openrisc
In-Reply-To: <20211119075844.2902592-1-calvinzhang.cool@gmail.com>

On Fri, Nov 19, 2021 at 03:58:17PM +0800, Calvin Zhang wrote:
> The count of reserved regions in /reserved-memory was limited because
> the struct reserved_mem array was defined statically. This series sorts
> out reserved memory code and allocates that array from early allocator.
> 
> Note: reserved region with fixed location must be reserved before any
> memory allocation. While struct reserved_mem array should be allocated
> after allocator is activated. We make early_init_fdt_scan_reserved_mem()
> do reservation only and add another call to initialize reserved memory.
> So arch code have to change for it.

I think much simpler would be to use the same constant for sizing
memblock.reserved and reserved_mem arrays.

If there is too much reserved regions in the device tree, reserving them in
memblock will fail anyway because memblock also starts with static array
for memblock.reserved, so doing one pass with memblock_reserve() and
another to set up reserved_mem wouldn't help anyway.

> I'm only familiar with arm and arm64 architectures. Approvals from arch
> maintainers are required. Thank you all.
> 
> Calvin Zhang (2):
>   of: Sort reserved_mem related code
>   of: reserved_mem: Remove reserved regions count restriction
> 
>  arch/arc/mm/init.c                 |   3 +
>  arch/arm/kernel/setup.c            |   2 +
>  arch/arm64/kernel/setup.c          |   3 +
>  arch/csky/kernel/setup.c           |   3 +
>  arch/h8300/kernel/setup.c          |   2 +
>  arch/mips/kernel/setup.c           |   3 +
>  arch/nds32/kernel/setup.c          |   3 +
>  arch/nios2/kernel/setup.c          |   2 +
>  arch/openrisc/kernel/setup.c       |   3 +
>  arch/powerpc/kernel/setup-common.c |   3 +
>  arch/riscv/kernel/setup.c          |   2 +
>  arch/sh/kernel/setup.c             |   3 +
>  arch/xtensa/kernel/setup.c         |   2 +
>  drivers/of/fdt.c                   | 107 +---------------
>  drivers/of/of_private.h            |  12 +-
>  drivers/of/of_reserved_mem.c       | 189 ++++++++++++++++++++++++-----
>  include/linux/of_reserved_mem.h    |   4 +
>  17 files changed, 207 insertions(+), 139 deletions(-)
> 
> -- 
> 2.30.2
> 

-- 
Sincerely yours,
Mike.

^ permalink raw reply

* Re: [PATCH 0/2] of: remove reserved regions count restriction
From: Calvin Zhang @ 2021-11-21  9:01 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Kirill A. Shutemov, Mark Rutland, Kefeng Wang, Rich Felker,
	Jinyang He, David Hildenbrand, Lee Jones, linux-kernel,
	Max Filippov, Anup Patel, Guo Ren, Guo Ren, linux-csky,
	Nick Kossifidis, Vladimir Isaev, Tiezhu Yang, Vincent Chen,
	Will Deacon, Markus Elfring, Vitaly Wool, Jonas Bonn, devicetree,
	linux-snps-arc, uclinux-h8-devel, Yoshinori Sato, Palmer Dabbelt,
	linux-sh, Rafael J. Wysocki, Russell King, Ley Foon Tan,
	Geert Uytterhoeven, Aneesh Kumar K.V, Catalin Marinas,
	Ganesh Goudar, David Brazdil, linux-riscv, Guenter Roeck,
	Alexander Sverdlin, Thierry Reding, Albert Ou, Arnd Bergmann,
	Anshuman Khandual, linux-xtensa, Vineet Gupta, Andreas Oetken,
	Stefan Kristiansson, Russell King (Oracle), Rob Herring,
	Christophe JAILLET, Greentime Hu, Paul Walmsley, Stafford Horne,
	Andy Shevchenko, linux-arm-kernel, Andrey Konovalov,
	Christophe Leroy, Chris Zankel, Thomas Bogendoerfer, linux-mips,
	Alexandre Ghiti, Nick Hu, Atish Patra, Greg Kroah-Hartman,
	Randy Dunlap, Frank Rowand, Serge Semin, Dinh Nguyen,
	Zhang Yunkai, Palmer Dabbelt, Souptick Joarder, Marc Zyngier,
	Mauri Sandberg, Paul Mackerras, Andrew Morton, linuxppc-dev,
	openrisc
In-Reply-To: <YZnqo3oA7srQik4N@kernel.org>

On Sun, Nov 21, 2021 at 08:43:47AM +0200, Mike Rapoport wrote:
>On Fri, Nov 19, 2021 at 03:58:17PM +0800, Calvin Zhang wrote:
>> The count of reserved regions in /reserved-memory was limited because
>> the struct reserved_mem array was defined statically. This series sorts
>> out reserved memory code and allocates that array from early allocator.
>> 
>> Note: reserved region with fixed location must be reserved before any
>> memory allocation. While struct reserved_mem array should be allocated
>> after allocator is activated. We make early_init_fdt_scan_reserved_mem()
>> do reservation only and add another call to initialize reserved memory.
>> So arch code have to change for it.
>
>I think much simpler would be to use the same constant for sizing
>memblock.reserved and reserved_mem arrays.
>
>If there is too much reserved regions in the device tree, reserving them in
>memblock will fail anyway because memblock also starts with static array
>for memblock.reserved, so doing one pass with memblock_reserve() and
>another to set up reserved_mem wouldn't help anyway.

Yes. This happens only if there are two many fixed reserved regions.
memblock.reserved can be resized after paging.

I also find another problem. Initializing dynamic reservation after
paging would fail to mark it no-map because no-map flag works when doing
direct mapping. This seems to be a circular dependency.

Thank You,
Calvin

^ permalink raw reply

* Re: [PATCH 1/8] powerpc/mm: Make slice specific to book3s/64
From: kernel test robot @ 2021-11-22 21:10 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, alex
  Cc: linux-mm, kbuild-all, linuxppc-dev, linux-kernel
In-Reply-To: <14e2c0b0d4fff49c1cb30166f54ce8e445e17b16.1637570556.git.christophe.leroy@csgroup.eu>

[-- Attachment #1: Type: text/plain, Size: 25175 bytes --]

Hi Christophe,

I love your patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on hnaz-mm/master linus/master v5.16-rc2 next-20211118]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Christophe-Leroy/Convert-powerpc-to-default-topdown-mmap-layout/20211122-165115
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc64-randconfig-r021-20211122 (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/1d0b7cc86d08f25f595b52d8c39ba9ca1d29a30a
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Christophe-Leroy/Convert-powerpc-to-default-topdown-mmap-layout/20211122-165115
        git checkout 1d0b7cc86d08f25f595b52d8c39ba9ca1d29a30a
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   arch/powerpc/mm/book3s64/slice.c: In function 'slice_get_unmapped_area':
>> arch/powerpc/mm/book3s64/slice.c:639:1: error: the frame size of 1056 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
     639 | }
         | ^
   cc1: all warnings being treated as errors


vim +639 arch/powerpc/mm/book3s64/slice.c

3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  428  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  429  unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  430  				      unsigned long flags, unsigned int psize,
34d07177b802e9 arch/powerpc/mm/slice.c Michel Lespinasse      2013-04-29  431  				      int topdown)
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  432  {
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  433  	struct slice_mask good_mask;
f3207c124e7aa8 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-03-22  434  	struct slice_mask potential_mask;
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  435  	const struct slice_mask *maskp;
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  436  	const struct slice_mask *compat_maskp = NULL;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  437  	int fixed = (flags & MAP_FIXED);
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  438  	int pshift = max_t(int, mmu_psize_defs[psize].shift, PAGE_SHIFT);
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  439  	unsigned long page_size = 1UL << pshift;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  440  	struct mm_struct *mm = current->mm;
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  441  	unsigned long newaddr;
f4ea6dcb08ea2c arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-03-30  442  	unsigned long high_limit;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  443  
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  444  	high_limit = DEFAULT_MAP_WINDOW;
35602f82d0c765 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  445  	if (addr >= high_limit || (fixed && (addr + len > high_limit)))
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  446  		high_limit = TASK_SIZE;
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  447  
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  448  	if (len > high_limit)
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  449  		return -ENOMEM;
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  450  	if (len & (page_size - 1))
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  451  		return -EINVAL;
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  452  	if (fixed) {
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  453  		if (addr & (page_size - 1))
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  454  			return -EINVAL;
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  455  		if (addr > high_limit - len)
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  456  			return -ENOMEM;
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  457  	}
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  458  
60458fba469a69 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2019-04-17  459  	if (high_limit > mm_ctx_slb_addr_limit(&mm->context)) {
5709f7cfd83052 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  460  		/*
5709f7cfd83052 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  461  		 * Increasing the slb_addr_limit does not require
5709f7cfd83052 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  462  		 * slice mask cache to be recalculated because it should
5709f7cfd83052 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  463  		 * be already initialised beyond the old address limit.
5709f7cfd83052 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  464  		 */
60458fba469a69 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2019-04-17  465  		mm_ctx_set_slb_addr_limit(&mm->context, high_limit);
54be0b9c7c9888 arch/powerpc/mm/slice.c Michael Ellerman       2018-10-02  466  
54be0b9c7c9888 arch/powerpc/mm/slice.c Michael Ellerman       2018-10-02  467  		on_each_cpu(slice_flush_segments, mm, 1);
f4ea6dcb08ea2c arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-03-30  468  	}
6a72dc038b6152 arch/powerpc/mm/slice.c Nicholas Piggin        2017-11-10  469  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  470  	/* Sanity checks */
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  471  	BUG_ON(mm->task_size == 0);
60458fba469a69 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2019-04-17  472  	BUG_ON(mm_ctx_slb_addr_limit(&mm->context) == 0);
764041e0f43cc7 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2016-04-29  473  	VM_BUG_ON(radix_enabled());
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  474  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  475  	slice_dbg("slice_get_unmapped_area(mm=%p, psize=%d...\n", mm, psize);
34d07177b802e9 arch/powerpc/mm/slice.c Michel Lespinasse      2013-04-29  476  	slice_dbg(" addr=%lx, len=%lx, flags=%lx, topdown=%d\n",
34d07177b802e9 arch/powerpc/mm/slice.c Michel Lespinasse      2013-04-29  477  		  addr, len, flags, topdown);
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  478  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  479  	/* If hint, make sure it matches our alignment restrictions */
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  480  	if (!fixed && addr) {
b711531641038f arch/powerpc/mm/slice.c Christophe Leroy       2020-04-20  481  		addr = ALIGN(addr, page_size);
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  482  		slice_dbg(" aligned addr=%lx\n", addr);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  483  		/* Ignore hint if it's too large or overlaps a VMA */
3b4d07d2674f6b arch/powerpc/mm/slice.c Aneesh Kumar K.V       2019-02-26  484  		if (addr > high_limit - len || addr < mmap_min_addr ||
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  485  		    !slice_area_is_free(mm, addr, len))
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  486  			addr = 0;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  487  	}
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  488  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  489  	/* First make up a "good" mask of slices that have the right size
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  490  	 * already
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  491  	 */
6f60cc98df2be7 arch/powerpc/mm/slice.c Christophe Leroy       2019-04-25  492  	maskp = slice_mask_for_size(&mm->context, psize);
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  493  
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  494  	/*
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  495  	 * Here "good" means slices that are already the right page size,
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  496  	 * "compat" means slices that have a compatible page size (i.e.
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  497  	 * 4k in a 64k pagesize kernel), and "free" means slices without
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  498  	 * any VMAs.
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  499  	 *
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  500  	 * If MAP_FIXED:
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  501  	 *	check if fits in good | compat => OK
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  502  	 *	check if fits in good | compat | free => convert free
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  503  	 *	else bad
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  504  	 * If have hint:
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  505  	 *	check if hint fits in good => OK
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  506  	 *	check if hint fits in good | free => convert free
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  507  	 * Otherwise:
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  508  	 *	search in good, found => OK
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  509  	 *	search in good | free, found => convert free
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  510  	 *	search in good | compat | free, found => convert free.
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  511  	 */
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  512  
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  513  	/*
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  514  	 * If we support combo pages, we can allow 64k pages in 4k slices
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  515  	 * The mask copies could be avoided in most cases here if we had
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  516  	 * a pointer to good mask for the next code to use.
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  517  	 */
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  518  	if (IS_ENABLED(CONFIG_PPC_64K_PAGES) && psize == MMU_PAGE_64K) {
6f60cc98df2be7 arch/powerpc/mm/slice.c Christophe Leroy       2019-04-25  519  		compat_maskp = slice_mask_for_size(&mm->context, MMU_PAGE_4K);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  520  		if (fixed)
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  521  			slice_or_mask(&good_mask, maskp, compat_maskp);
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  522  		else
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  523  			slice_copy_mask(&good_mask, maskp);
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  524  	} else {
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  525  		slice_copy_mask(&good_mask, maskp);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  526  	}
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  527  
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  528  	slice_print_mask(" good_mask", &good_mask);
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  529  	if (compat_maskp)
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  530  		slice_print_mask(" compat_mask", compat_maskp);
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  531  
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  532  	/* First check hint if it's valid or if we have MAP_FIXED */
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  533  	if (addr != 0 || fixed) {
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  534  		/* Check if we fit in the good mask. If we do, we just return,
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  535  		 * nothing else to do
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  536  		 */
ae3066bd1cbe58 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  537  		if (slice_check_range_fits(mm, &good_mask, addr, len)) {
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  538  			slice_dbg(" fits good !\n");
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  539  			newaddr = addr;
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  540  			goto return_addr;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  541  		}
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  542  	} else {
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  543  		/* Now let's see if we can find something in the existing
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  544  		 * slices for that size
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  545  		 */
830fd2d45aa116 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  546  		newaddr = slice_find_area(mm, len, &good_mask,
f4ea6dcb08ea2c arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-03-30  547  					  psize, topdown, high_limit);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  548  		if (newaddr != -ENOMEM) {
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  549  			/* Found within the good mask, we don't have to setup,
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  550  			 * we thus return directly
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  551  			 */
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  552  			slice_dbg(" found area at 0x%lx\n", newaddr);
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  553  			goto return_addr;
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  554  		}
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  555  	}
7a06c66835f75f arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-11-10  556  	/*
7a06c66835f75f arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-11-10  557  	 * We don't fit in the good mask, check what other slices are
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  558  	 * empty and thus can be converted
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  559  	 */
7a06c66835f75f arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-11-10  560  	slice_mask_for_free(mm, &potential_mask, high_limit);
b8c93549142077 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  561  	slice_or_mask(&potential_mask, &potential_mask, &good_mask);
830fd2d45aa116 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  562  	slice_print_mask(" potential", &potential_mask);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  563  
ae3066bd1cbe58 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  564  	if (addr != 0 || fixed) {
ae3066bd1cbe58 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  565  		if (slice_check_range_fits(mm, &potential_mask, addr, len)) {
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  566  			slice_dbg(" fits potential !\n");
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  567  			newaddr = addr;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  568  			goto convert;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  569  		}
ae3066bd1cbe58 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  570  	}
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  571  
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  572  	/* If we have MAP_FIXED and failed the above steps, then error out */
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  573  	if (fixed)
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  574  		return -EBUSY;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  575  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  576  	slice_dbg(" search...\n");
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  577  
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  578  	/* If we had a hint that didn't work out, see if we can fit
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  579  	 * anywhere in the good area.
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  580  	 */
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  581  	if (addr) {
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  582  		newaddr = slice_find_area(mm, len, &good_mask,
f4ea6dcb08ea2c arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-03-30  583  					  psize, topdown, high_limit);
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  584  		if (newaddr != -ENOMEM) {
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  585  			slice_dbg(" found area at 0x%lx\n", newaddr);
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  586  			goto return_addr;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  587  		}
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  588  	}
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  589  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  590  	/* Now let's see if we can find something in the existing slices
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  591  	 * for that size plus free slices
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  592  	 */
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  593  	newaddr = slice_find_area(mm, len, &potential_mask,
f4ea6dcb08ea2c arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-03-30  594  				  psize, topdown, high_limit);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  595  
203a1fa6286671 arch/powerpc/mm/slice.c Christophe Leroy       2019-04-25  596  	if (IS_ENABLED(CONFIG_PPC_64K_PAGES) && newaddr == -ENOMEM &&
203a1fa6286671 arch/powerpc/mm/slice.c Christophe Leroy       2019-04-25  597  	    psize == MMU_PAGE_64K) {
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  598  		/* retry the search with 4k-page slices included */
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  599  		slice_or_mask(&potential_mask, &potential_mask, compat_maskp);
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  600  		newaddr = slice_find_area(mm, len, &potential_mask,
f4ea6dcb08ea2c arch/powerpc/mm/slice.c Aneesh Kumar K.V       2017-03-30  601  					  psize, topdown, high_limit);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  602  	}
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  603  
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  604  	if (newaddr == -ENOMEM)
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  605  		return -ENOMEM;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  606  
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  607  	slice_range_to_mask(newaddr, len, &potential_mask);
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  608  	slice_dbg(" found potential area at 0x%lx\n", newaddr);
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  609  	slice_print_mask(" mask", &potential_mask);
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  610  
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  611   convert:
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  612  	/*
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  613  	 * Try to allocate the context before we do slice convert
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  614  	 * so that we handle the context allocation failure gracefully.
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  615  	 */
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  616  	if (need_extra_context(mm, newaddr)) {
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  617  		if (alloc_extended_context(mm, newaddr) < 0)
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  618  			return -ENOMEM;
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  619  	}
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  620  
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  621  	slice_andnot_mask(&potential_mask, &potential_mask, &good_mask);
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  622  	if (compat_maskp && !fixed)
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  623  		slice_andnot_mask(&potential_mask, &potential_mask, compat_maskp);
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  624  	if (potential_mask.low_slices ||
db3a528db41caa arch/powerpc/mm/slice.c Christophe Leroy       2018-02-22  625  		(SLICE_NUM_HIGH &&
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  626  		 !bitmap_empty(potential_mask.high_slices, SLICE_NUM_HIGH))) {
d262bd5a739982 arch/powerpc/mm/slice.c Nicholas Piggin        2018-03-07  627  		slice_convert(mm, &potential_mask, psize);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  628  		if (psize > MMU_PAGE_BASE)
54be0b9c7c9888 arch/powerpc/mm/slice.c Michael Ellerman       2018-10-02  629  			on_each_cpu(slice_flush_segments, mm, 1);
3a8247cc2c8569 arch/powerpc/mm/slice.c Paul Mackerras         2008-06-18  630  	}
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  631  	return newaddr;
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  632  
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  633  return_addr:
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  634  	if (need_extra_context(mm, newaddr)) {
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  635  		if (alloc_extended_context(mm, newaddr) < 0)
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  636  			return -ENOMEM;
f384796c40dc55 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  637  	}
0dea04b288c066 arch/powerpc/mm/slice.c Aneesh Kumar K.V       2018-03-26  638  	return newaddr;
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08 @639  }
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  640  EXPORT_SYMBOL_GPL(slice_get_unmapped_area);
d0f13e3c20b6fb arch/powerpc/mm/slice.c Benjamin Herrenschmidt 2007-05-08  641  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 43404 bytes --]

^ permalink raw reply

* Re: [RFC patch 0/5] Support BCLK input clock in tlv320aic31xx
From: Mark Brown @ 2021-11-23  0:00 UTC (permalink / raw)
  To: alsa-devel, linuxppc-dev, Ariel D'Alessandro, linux-kernel
  Cc: bkylerussell, kuninori.morimoto.gx, Xiubo.Lee, shengjiu.wang,
	tiwai, lgirdwood, perex, nicoleotsuka, michael, festevam
In-Reply-To: <20211119153248.419802-1-ariel.dalessandro@collabora.com>

On Fri, 19 Nov 2021 12:32:43 -0300, Ariel D'Alessandro wrote:
> The tlv320aic31xx codec allows using BCLK as the input clock for PLL,
> deriving all the frequencies through a set of divisors.
> 
> In this case, codec sysclk is determined by the hwparams sample
> rate/format. So its frequency must be updated from the codec itself when
> these are changed.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/5] ASoC: tlv320aic31xx: Fix typo in BCLK clock name
      commit: 7016fd940adf2f4d86032339b546c6ecd737062f
[2/5] ASoC: tlv320aic31xx: Add support for pll_r coefficient
      commit: 2664b24a8c51c21b24c2b37b7f10d6485c35b7c1
[3/5] ASoC: tlv320aic31xx: Add divs for bclk as clk_in
      commit: 6e6752a9c78738e27bde6da5cefa393b589276bb
[4/5] ASoC: tlv320aic31xx: Handle BCLK set as PLL input configuration
      commit: c5d22d5e12e776fee4e346dc098fe51d00c2f983
[5/5] ASoC: fsl-asoc-card: Support fsl,imx-audio-tlv320aic31xx codec
      commit: 8c9b9cfb7724685ce705f511b882f30597596536

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply

* Re: [PATCH 6/8] mm: Allow arch specific arch_randomize_brk() with CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
From: kernel test robot @ 2021-11-23  0:22 UTC (permalink / raw)
  To: Christophe Leroy, Benjamin Herrenschmidt, Paul Mackerras,
	Michael Ellerman, alex
  Cc: linuxppc-dev, kbuild-all, linux-kernel, linux-mm
In-Reply-To: <e2209d0f1f3c1b581592bd6c32243402ccfe3dde.1637570556.git.christophe.leroy@csgroup.eu>

[-- Attachment #1: Type: text/plain, Size: 1798 bytes --]

Hi Christophe,

I love your patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on hnaz-mm/master linus/master v5.16-rc2 next-20211118]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Christophe-Leroy/Convert-powerpc-to-default-topdown-mmap-layout/20211122-165115
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: arm-randconfig-r005-20211122 (attached as .config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/e5949ff1a8e5cae8e9ac2ec3a39849bf2e73eb34
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Christophe-Leroy/Convert-powerpc-to-default-topdown-mmap-layout/20211122-165115
        git checkout e5949ff1a8e5cae8e9ac2ec3a39849bf2e73eb34
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   arm-linux-gnueabi-ld: fs/binfmt_elf.o: in function `load_elf_binary':
>> binfmt_elf.c:(.text+0x16d8): undefined reference to `arch_randomize_brk'

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35957 bytes --]

^ permalink raw reply

* Re: [PATCH v2] powerpc/64s: introduce CONFIG_MAXSMP to test very large SMP
From: Michael Ellerman @ 2021-11-23  1:01 UTC (permalink / raw)
  To: Christophe Leroy, Nicholas Piggin, linuxppc-dev
In-Reply-To: <87ilwzm18j.fsf@mpe.ellerman.id.au>

Michael Ellerman <mpe@ellerman.id.au> writes:
> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>> Le 09/11/2021 à 07:51, Nicholas Piggin a écrit :
> ...
>>> diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
>>> index a208997ade88..14c275e0ff93 100644
>>> --- a/arch/powerpc/platforms/Kconfig.cputype
>>> +++ b/arch/powerpc/platforms/Kconfig.cputype
>>> @@ -475,9 +475,14 @@ config SMP
>>>   
>>>   	  If you don't know what to do here, say N.
>>>   
>>> +# MAXSMP sets 8192 if COMPILE_TEST because that's what x86 has flushed out.
>>> +# Exceeding that will cause a lot of compile errors. Have to deal with those
>>> +# first.
>>>   config NR_CPUS
>>> -	int "Maximum number of CPUs (2-8192)" if SMP
>>> -	range 2 8192 if SMP
>>> +	int "Maximum number of CPUs (2-8192)" if SMP && !MAXSMP
>>> +	range 2 16384 if SMP
>>> +	default 16384 if MAXSMP && !COMPILE_TEST
>>> +	default 8192 if MAXSMP && COMPILE_TEST
>>
>> You can do less complex. First hit becomes the default, so you can do:
>>
>> 	default 8192 if MAXSMP && COMPILE_TEST
>> 	default 16384 if MAXSMP
>
> I did that when applying.

But I'll have to drop it, it breaks the allyesconfig build:

  In file included from /home/michael/linux/arch/powerpc/include/asm/paravirt.h:15,
                   from /home/michael/linux/arch/powerpc/include/asm/qspinlock.h:6,
                   from /home/michael/linux/arch/powerpc/include/asm/spinlock.h:7,
                   from /home/michael/linux/include/linux/spinlock.h:93,
                   from /home/michael/linux/include/linux/mmzone.h:8,
                   from /home/michael/linux/include/linux/gfp.h:6,
                   from /home/michael/linux/include/linux/mm.h:10,
                   from /home/michael/linux/arch/powerpc/platforms/powernv/idle.c:9:
  /home/michael/linux/arch/powerpc/include/asm/cputhreads.h: In function ‘cpu_thread_mask_to_cores.constprop’:
  /home/michael/linux/arch/powerpc/include/asm/cputhreads.h:61:1: error: the frame size of 2064 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
     61 | }
        | ^
  /home/michael/linux/arch/powerpc/platforms/powernv/idle.c: In function ‘store_fastsleep_workaround_applyonce’:
  /home/michael/linux/arch/powerpc/platforms/powernv/idle.c:220:1: error: the frame size of 2080 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
    220 | }
        | ^
  cc1: all warnings being treated as errors
  make[4]: *** [/home/michael/linux/scripts/Makefile.build:287: arch/powerpc/platforms/powernv/idle.o] Error 1
  make[4]: *** Waiting for unfinished jobs....
  make[3]: *** [/home/michael/linux/scripts/Makefile.build:549: arch/powerpc/platforms/powernv] Error 2
  make[3]: *** Waiting for unfinished jobs....
  /home/michael/linux/arch/powerpc/kvm/book3s_hv_interrupts.S: Assembler messages:
  /home/michael/linux/arch/powerpc/kvm/book3s_hv_interrupts.S:66: Error: operand out of range (0x0000000000010440 is not between 0xffffffffffff8000 and 0x0000000000007ffc)
  make[3]: *** [/home/michael/linux/scripts/Makefile.build:388: arch/powerpc/kvm/book3s_hv_interrupts.o] Error 1
  make[3]: *** Waiting for unfinished jobs....
  make[2]: *** [/home/michael/linux/scripts/Makefile.build:549: arch/powerpc/platforms] Error 2
  make[2]: *** Waiting for unfinished jobs....
  make[2]: *** [/home/michael/linux/scripts/Makefile.build:549: arch/powerpc/kvm] Error 2
  make[1]: *** [/home/michael/linux/Makefile:1846: arch/powerpc] Error 2
  make[1]: *** Waiting for unfinished jobs....
  make: *** [Makefile:219: __sub-make] Error 2

cheers

^ permalink raw reply

* Re: [PATCH v2] powerpc/64s: introduce CONFIG_MAXSMP to test very large SMP
From: Nicholas Piggin @ 2021-11-23  5:14 UTC (permalink / raw)
  To: Christophe Leroy, linuxppc-dev, Michael Ellerman
In-Reply-To: <87czmrr8hb.fsf@mpe.ellerman.id.au>

Excerpts from Michael Ellerman's message of November 23, 2021 11:01 am:
> Michael Ellerman <mpe@ellerman.id.au> writes:
>> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>>> Le 09/11/2021 à 07:51, Nicholas Piggin a écrit :
>> ...
>>>> diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
>>>> index a208997ade88..14c275e0ff93 100644
>>>> --- a/arch/powerpc/platforms/Kconfig.cputype
>>>> +++ b/arch/powerpc/platforms/Kconfig.cputype
>>>> @@ -475,9 +475,14 @@ config SMP
>>>>   
>>>>   	  If you don't know what to do here, say N.
>>>>   
>>>> +# MAXSMP sets 8192 if COMPILE_TEST because that's what x86 has flushed out.
>>>> +# Exceeding that will cause a lot of compile errors. Have to deal with those
>>>> +# first.
>>>>   config NR_CPUS
>>>> -	int "Maximum number of CPUs (2-8192)" if SMP
>>>> -	range 2 8192 if SMP
>>>> +	int "Maximum number of CPUs (2-8192)" if SMP && !MAXSMP
>>>> +	range 2 16384 if SMP
>>>> +	default 16384 if MAXSMP && !COMPILE_TEST
>>>> +	default 8192 if MAXSMP && COMPILE_TEST
>>>
>>> You can do less complex. First hit becomes the default, so you can do:
>>>
>>> 	default 8192 if MAXSMP && COMPILE_TEST
>>> 	default 16384 if MAXSMP
>>
>> I did that when applying.
> 
> But I'll have to drop it, it breaks the allyesconfig build:

Ah, you still need patch 1/2 sorry I confused things by only re-sending 
this one.

https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20211105035042.1398309-1-npiggin@gmail.com/

Thanks,
Nick

> 
>   In file included from /home/michael/linux/arch/powerpc/include/asm/paravirt.h:15,
>                    from /home/michael/linux/arch/powerpc/include/asm/qspinlock.h:6,
>                    from /home/michael/linux/arch/powerpc/include/asm/spinlock.h:7,
>                    from /home/michael/linux/include/linux/spinlock.h:93,
>                    from /home/michael/linux/include/linux/mmzone.h:8,
>                    from /home/michael/linux/include/linux/gfp.h:6,
>                    from /home/michael/linux/include/linux/mm.h:10,
>                    from /home/michael/linux/arch/powerpc/platforms/powernv/idle.c:9:
>   /home/michael/linux/arch/powerpc/include/asm/cputhreads.h: In function ‘cpu_thread_mask_to_cores.constprop’:
>   /home/michael/linux/arch/powerpc/include/asm/cputhreads.h:61:1: error: the frame size of 2064 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
>      61 | }
>         | ^
>   /home/michael/linux/arch/powerpc/platforms/powernv/idle.c: In function ‘store_fastsleep_workaround_applyonce’:
>   /home/michael/linux/arch/powerpc/platforms/powernv/idle.c:220:1: error: the frame size of 2080 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
>     220 | }
>         | ^
>   cc1: all warnings being treated as errors
>   make[4]: *** [/home/michael/linux/scripts/Makefile.build:287: arch/powerpc/platforms/powernv/idle.o] Error 1
>   make[4]: *** Waiting for unfinished jobs....
>   make[3]: *** [/home/michael/linux/scripts/Makefile.build:549: arch/powerpc/platforms/powernv] Error 2
>   make[3]: *** Waiting for unfinished jobs....
>   /home/michael/linux/arch/powerpc/kvm/book3s_hv_interrupts.S: Assembler messages:
>   /home/michael/linux/arch/powerpc/kvm/book3s_hv_interrupts.S:66: Error: operand out of range (0x0000000000010440 is not between 0xffffffffffff8000 and 0x0000000000007ffc)
>   make[3]: *** [/home/michael/linux/scripts/Makefile.build:388: arch/powerpc/kvm/book3s_hv_interrupts.o] Error 1
>   make[3]: *** Waiting for unfinished jobs....
>   make[2]: *** [/home/michael/linux/scripts/Makefile.build:549: arch/powerpc/platforms] Error 2
>   make[2]: *** Waiting for unfinished jobs....
>   make[2]: *** [/home/michael/linux/scripts/Makefile.build:549: arch/powerpc/kvm] Error 2
>   make[1]: *** [/home/michael/linux/Makefile:1846: arch/powerpc] Error 2
>   make[1]: *** Waiting for unfinished jobs....
>   make: *** [Makefile:219: __sub-make] Error 2
> 
> cheers
> 

^ permalink raw reply

* Re: [PATCH v2] powerpc/64s: introduce CONFIG_MAXSMP to test very large SMP
From: Nicholas Piggin @ 2021-11-23  5:16 UTC (permalink / raw)
  To: Christophe Leroy, linuxppc-dev, Michael Ellerman
In-Reply-To: <1637644417.rd9apgh5k7.astroid@bobo.none>

Excerpts from Nicholas Piggin's message of November 23, 2021 3:14 pm:
> Excerpts from Michael Ellerman's message of November 23, 2021 11:01 am:
>> Michael Ellerman <mpe@ellerman.id.au> writes:
>>> Christophe Leroy <christophe.leroy@csgroup.eu> writes:
>>>> Le 09/11/2021 à 07:51, Nicholas Piggin a écrit :
>>> ...
>>>>> diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
>>>>> index a208997ade88..14c275e0ff93 100644
>>>>> --- a/arch/powerpc/platforms/Kconfig.cputype
>>>>> +++ b/arch/powerpc/platforms/Kconfig.cputype
>>>>> @@ -475,9 +475,14 @@ config SMP
>>>>>   
>>>>>   	  If you don't know what to do here, say N.
>>>>>   
>>>>> +# MAXSMP sets 8192 if COMPILE_TEST because that's what x86 has flushed out.
>>>>> +# Exceeding that will cause a lot of compile errors. Have to deal with those
>>>>> +# first.
>>>>>   config NR_CPUS
>>>>> -	int "Maximum number of CPUs (2-8192)" if SMP
>>>>> -	range 2 8192 if SMP
>>>>> +	int "Maximum number of CPUs (2-8192)" if SMP && !MAXSMP
>>>>> +	range 2 16384 if SMP
>>>>> +	default 16384 if MAXSMP && !COMPILE_TEST
>>>>> +	default 8192 if MAXSMP && COMPILE_TEST
>>>>
>>>> You can do less complex. First hit becomes the default, so you can do:
>>>>
>>>> 	default 8192 if MAXSMP && COMPILE_TEST
>>>> 	default 16384 if MAXSMP
>>>
>>> I did that when applying.
>> 
>> But I'll have to drop it, it breaks the allyesconfig build:
> 
> Ah, you still need patch 1/2 sorry I confused things by only re-sending 
> this one.
> 
> https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20211105035042.1398309-1-npiggin@gmail.com/

Actually KVM will also be broken, I sent a patch for it but there is 
some discussion of fixing it a different way. So maybe leave out the
maxsmp patch for now (or make it depend on BROKEN?). I can re-send
maybe next merge window if the other pieces are in place.

If you could still take that ^^ patch for now would be good though.

Thanks,
Nick

^ permalink raw reply

* Re: [PATCH V4 0/1] powerpc/perf: Clear pending PMI in ppmu callbacks
From: Nicholas Piggin @ 2021-11-23  5:24 UTC (permalink / raw)
  To: Athira Rajeev, mpe; +Cc: maddy, linuxppc-dev, rnsastry
In-Reply-To: <40F23366-66BE-4063-8516-445E41E19EC6@linux.vnet.ibm.com>

Excerpts from Athira Rajeev's message of November 20, 2021 12:36 am:
> 
> 
>> On 21-Jul-2021, at 11:18 AM, Athira Rajeev <atrajeev@linux.vnet.ibm.com> wrote:
>> 
>> Running perf fuzzer testsuite popped up below messages
>> in the dmesg logs:
>> 
>> "Can't find PMC that caused IRQ"
>> 
>> This means a PMU exception happened, but none of the PMC's (Performance
>> Monitor Counter) were found to be overflown. Perf interrupt handler checks
>> the PMC's to see which PMC has overflown and if none of the PMCs are
>> overflown ( counter value not >= 0x80000000 ), it throws warning:
>> "Can't find PMC that caused IRQ".
>> 
>> Powerpc has capability to mask and replay a performance monitoring
>> interrupt (PMI). In case of replayed PMI, there are some corner cases
>> that clears the PMCs after masking. In such cases, the perf interrupt
>> handler will not find the active PMC values that had caused the overflow
>> and thus leading to this message. This patchset attempts to fix those
>> corner cases.
>> 
>> However there is one more case in PowerNV where these messages are
>> emitted during system wide profiling or when a specific CPU is monitored
>> for an event. That is, when a counter overflow just before entering idle
>> and a PMI gets triggered after wakeup from idle. Since PMCs
>> are not saved in the idle path, perf interrupt handler will not
>> find overflown counter value and emits the "Can't find PMC" messages.
>> This patch documents this race condition in powerpc core-book3s.
>> 
>> Patch fixes the ppmu callbacks to disable pending interrupt before clearing
>> the overflown PMC and documents the race condition in idle path.
>> 
>> Changelog:
>> changes from v3 -> v4
>>   Addressed review comments from Nicholas Piggin
>>   - Added comment explaining the need to clear MMCR0 PMXE bit in
>>     pmu disable callback.
>>   - Added a check to display warning if there is a PMI pending
>>     bit set in Paca without any overflown PMC.
>>   - Removed the condition check before clearing pending PMI
>>     in 'clear_pmi_irq_pending' function.
>>   - Added reviewed by from Nicholas Piggin.
>> 
>> Changes from v2 -> v3
>>   Addressed review comments from Nicholas Piggin
>>   - Moved the clearing of PMI bit to power_pmu_disable.
>>     In previous versions, this was done in power_pmu_del,
>>     power_pmu_stop/enable callbacks before clearing of PMC's.
>>   - power_pmu_disable is called before any event gets deleted
>>     or stopped. If more than one event is running in the PMU,
>>     we may clear the PMI bit for an event which is not going
>>     to be deleted/stopped. Hence introduced check in
>>     power_pmu_enable to set back PMI to avoid dropping of valid
>>     samples in such cases.
>>   - Disable MMCR0 PMXE bit in pmu disable callback which otherwise
>>     could trigger PMI when PMU is getting disabled.
>> Changes from v1 -> v2
>>   Addressed review comments from Nicholas Piggin
>>   - Moved the PMI pending check and clearing function
>>     to arch/powerpc/include/asm/hw_irq.h and renamed
>>     function to "get_clear_pmi_irq_pending"
>>   - Along with checking for pending PMI bit in Paca,
>>     look for PMAO bit in MMCR0 register to decide on
>>     pending PMI interrupt.
>> 
>> Athira Rajeev (1):
>>  powerpc/perf: Fix PMU callbacks to clear pending PMI before resetting
>>    an overflown PMC
> 
> Hi,
> 
> Please let me know if there are any review comments for this patch.
> 
> Thanks
> Athira

It seems good to me. It already has my R-B. Would be good if we can
get this one merged.

Thanks,
Nick

^ permalink raw reply

* [PATCH] powerpc/module_64: Fix livepatching for RO modules
From: Russell Currey @ 2021-11-23  8:15 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Joe Lawrence, jniethe5, Russell Currey, naveen.n.rao

Livepatching a loaded module involves applying relocations through
apply_relocate_add(), which attempts to write to read-only memory when
CONFIG_STRICT_MODULE_RWX=y.  Work around this by performing these
writes through the text poke area by using patch_instruction().

R_PPC_REL24 is the only relocation type generated by the kpatch-build
userspace tool or klp-convert kernel tree that I observed applying a
relocation to a post-init module.

A more comprehensive solution is planned, but using patch_instruction()
for R_PPC_REL24 on should serve as a sufficient fix.

This does have a performance impact, I observed ~15% overhead in
module_load() on POWER8 bare metal with checksum verification off.

Fixes: c35717c71e98 ("powerpc: Set ARCH_HAS_STRICT_MODULE_RWX")
Cc: stable@vger.kernel.org # v5.14+
Reported-by: Joe Lawrence <joe.lawrence@redhat.com>
Signed-off-by: Russell Currey <ruscur@russell.cc>
---
Intended to be a minimal fix that can go to stable.

 arch/powerpc/kernel/module_64.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 6baa676e7cb6..c25ef36c3ef4 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -422,11 +422,16 @@ static inline int create_stub(const Elf64_Shdr *sechdrs,
 			      const char *name)
 {
 	long reladdr;
+	func_desc_t desc;
+	int i;
 
 	if (is_mprofile_ftrace_call(name))
 		return create_ftrace_stub(entry, addr, me);
 
-	memcpy(entry->jump, ppc64_stub_insns, sizeof(ppc64_stub_insns));
+	for (i = 0; i < sizeof(ppc64_stub_insns) / sizeof(u32); i++) {
+		patch_instruction(&entry->jump[i],
+				  ppc_inst(ppc64_stub_insns[i]));
+	}
 
 	/* Stub uses address relative to r2. */
 	reladdr = (unsigned long)entry - my_r2(sechdrs, me);
@@ -437,10 +442,19 @@ static inline int create_stub(const Elf64_Shdr *sechdrs,
 	}
 	pr_debug("Stub %p get data from reladdr %li\n", entry, reladdr);
 
-	entry->jump[0] |= PPC_HA(reladdr);
-	entry->jump[1] |= PPC_LO(reladdr);
-	entry->funcdata = func_desc(addr);
-	entry->magic = STUB_MAGIC;
+	patch_instruction(&entry->jump[0],
+			  ppc_inst(entry->jump[0] | PPC_HA(reladdr)));
+	patch_instruction(&entry->jump[1],
+			  ppc_inst(entry->jump[1] | PPC_LO(reladdr)));
+
+	// func_desc_t is 8 bytes if ABIv2, else 16 bytes
+	desc = func_desc(addr);
+	for (i = 0; i < sizeof(func_desc_t) / sizeof(u32); i++) {
+		patch_instruction(((u32 *)&entry->funcdata) + i,
+				  ppc_inst(((u32 *)(&desc))[i]));
+	}
+
+	patch_instruction(&entry->magic, ppc_inst(STUB_MAGIC));
 
 	return 1;
 }
@@ -496,7 +510,7 @@ static int restore_r2(const char *name, u32 *instruction, struct module *me)
 		return 0;
 	}
 	/* ld r2,R2_STACK_OFFSET(r1) */
-	*instruction = PPC_INST_LD_TOC;
+	patch_instruction(instruction, ppc_inst(PPC_INST_LD_TOC));
 	return 1;
 }
 
@@ -636,9 +650,9 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
 			}
 
 			/* Only replace bits 2 through 26 */
-			*(uint32_t *)location
-				= (*(uint32_t *)location & ~0x03fffffc)
+			value = (*(uint32_t *)location & ~0x03fffffc)
 				| (value & 0x03fffffc);
+			patch_instruction((u32 *)location, ppc_inst(value));
 			break;
 
 		case R_PPC64_REL64:
-- 
2.34.0


^ permalink raw reply related

* Re: [PATCH v5 05/12] KVM: RISC-V: Use Makefile.kvm for common files
From: Anup Patel @ 2021-11-23  9:12 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Anup Patel, wanpengli @ tencent . com, kvm, Joao Martins,
	Will Deacon, kvmarm, linux-s390, joro @ 8bytes . org, Huacai Chen,
	Christian Borntraeger, Aleksandar Markovic, karahmed,
	Catalin Marinas, Suzuki K Poulose, butt3rflyh4ck, Boris Ostrovsky,
	Alexandru Elisei, linux-arm-kernel, jmattson @ google . com,
	seanjc @ google . com, mtosatti @ redhat . com, linux-mips,
	James Morse, kvm-riscv, Marc Zyngier, Paolo Bonzini,
	vkuznets @ redhat . com, linuxppc-dev
In-Reply-To: <20211121125451.9489-6-dwmw2@infradead.org>

On Sun, Nov 21, 2021 at 6:25 PM David Woodhouse <dwmw2@infradead.org> wrote:
>
> From: David Woodhouse <dwmw@amazon.co.uk>
>
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>

Looks good to me.

For KVM RISC-V,
Acked-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Anup Patel <anup.patel@wdc.com>

Thanks,
Anup

> ---
>  arch/riscv/kvm/Makefile | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/arch/riscv/kvm/Makefile b/arch/riscv/kvm/Makefile
> index 30cdd1df0098..300590225348 100644
> --- a/arch/riscv/kvm/Makefile
> +++ b/arch/riscv/kvm/Makefile
> @@ -5,14 +5,10 @@
>
>  ccflags-y += -I $(srctree)/$(src)
>
> -KVM := ../../../virt/kvm
> +include $(srctree)/virt/kvm/Makefile.kvm
>
>  obj-$(CONFIG_KVM) += kvm.o
>
> -kvm-y += $(KVM)/kvm_main.o
> -kvm-y += $(KVM)/coalesced_mmio.o
> -kvm-y += $(KVM)/binary_stats.o
> -kvm-y += $(KVM)/eventfd.o
>  kvm-y += main.o
>  kvm-y += vm.o
>  kvm-y += vmid.o
> --
> 2.31.1
>

^ permalink raw reply

* [PATCH v4 00/53] KVM: PPC: Book3S HV P9: entry/exit optimisations
From: Nicholas Piggin @ 2021-11-23  9:51 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin

This reduces radix guest full entry/exit latency on POWER9 and POWER10
by 2x.

Nested HV guests should see smaller improvements in their L1 entry/exit,
but this is also combined with most L0 speedups also applying to nested
entry. nginx localhost throughput test in a SMP nested guest is improved
about 10% (in a direct guest it doesn't change much because it uses XIVE
for IPIs) when L0 and L1 are patched.

It does this in several main ways:

- Rearrange code to optimise SPR accesses. Mainly, avoid scoreboard
  stalls.

- Test SPR values to avoid mtSPRs where possible. mtSPRs are expensive.

- Reduce mftb. mftb is expensive.

- Demand fault certain facilities to avoid saving and/or restoring them
  (at the cost of fault when they are used, but this is mitigated over
  a number of entries, like the facilities when context switching 
  processes). PM, TM, and EBB so far.

- Defer some sequences that are made just in case a guest is interrupted
  in the middle of a critical section to the case where the guest is
  scheduled on a different CPU, rather than every time (at the cost of
  an extra IPI in this case). Namely the tlbsync sequence for radix with
  GTSE, which is very expensive.

- Reduce locking, barriers, atomics related to the vcpus-per-vcore > 1
  handling that the P9 path does not require.

Changes since v3:
- Fix a possible bug in "Avoid tlbsync sequence on radix guest exit"
  where the TLB flushing optimisation (1 thread TLBIEL flushes TLB for
  entire core) might break because 'ptesync' was no longer guaranteed
  to be executed on all threads (via regular exit path). Now the TLB
  flush keeps track of all threads and whether they need to do a TLBIEL
  or a PTESYNC. Fixing this requires a new patch "Split P8 from P9 path
  guest vCPU TLB flushing".

Changes since v2:
- Rebased, several patches from the series were merged in the previous
  merge window.
- Fixed some compile errors noticed by kernel test robot.
- Added RB from Athira for the PMU stuff (thanks!)
- Split TIDR ftr check (patch 2) out into its own patch.
- Added a missed license tag on new file.

Changes since v1:
- Verified DPDES changes still work with msgsndp SMT emulation.
- Fixed HMI handling bug.
- Split softpatch handling fixes into smaller pieces.
- Rebased with Fabiano's latest HV sanitising patches.
- Fix TM demand faulting bug causing nested guest TM tests to TM Bad
  Thing the host in rare cases.
- Re-name new "pmu=" command line option to "pmu_override=" and update
  documentation wording.
- Add default=y config option rather than unconditionally removing the
  L0 nested PMU workaround.
- Remove unnecessary MSR[RI] updates in entry/exit. Down to about 4700
  cycles now.
- Another bugfix from Alexey's testing.

Changes since RFC:
- Rebased with Fabiano's HV sanitising patches at the front.
- Several demand faulting bug fixes mostly relating to nested guests.
- Removed facility demand-faulting from L0 nested entry/exit handler.
  Demand faulting is still done in the L1, but not the L0. The reason
  is to reduce complexity (although it's only a small amount of
  complexity), reduce demand faulting overhead that may require several

Thanks,
Nick

Nicholas Piggin (53):
  powerpc/64s: Remove WORT SPR from POWER9/10 (take 2)
  powerpc/64s: guard optional TIDR SPR with CPU ftr test
  KMV: PPC: Book3S HV P9: Use set_dec to set decrementer to host
  KVM: PPC: Book3S HV P9: Use host timer accounting to avoid decrementer
    read
  KVM: PPC: Book3S HV P9: Use large decrementer for HDEC
  KVM: PPC: Book3S HV P9: Reduce mftb per guest entry/exit
  powerpc/time: add API for KVM to re-arm the host timer/decrementer
  KVM: PPC: Book3S HV: POWER10 enable HAIL when running radix guests
  powerpc/64s: Keep AMOR SPR a constant ~0 at runtime
  KVM: PPC: Book3S HV: Don't always save PMU for guest capable of
    nesting
  powerpc/64s: Always set PMU control registers to frozen/disabled when
    not in use
  powerpc/64s: Implement PMU override command line option
  KVM: PPC: Book3S HV P9: Implement PMU save/restore in C
  KVM: PPC: Book3S HV P9: Factor PMU save/load into context switch
    functions
  KVM: PPC: Book3S HV P9: Demand fault PMU SPRs when marked not inuse
  KVM: PPC: Book3S HV P9: Factor out yield_count increment
  KVM: PPC: Book3S HV: CTRL SPR does not require read-modify-write
  KVM: PPC: Book3S HV P9: Move SPRG restore to restore_p9_host_os_sprs
  KVM: PPC: Book3S HV P9: Reduce mtmsrd instructions required to save
    host SPRs
  KVM: PPC: Book3S HV P9: Improve mtmsrd scheduling by delaying MSR[EE]
    disable
  KVM: PPC: Book3S HV P9: Add kvmppc_stop_thread to match
    kvmppc_start_thread
  KVM: PPC: Book3S HV: Change dec_expires to be relative to guest
    timebase
  KVM: PPC: Book3S HV P9: Move TB updates
  KVM: PPC: Book3S HV P9: Optimise timebase reads
  KVM: PPC: Book3S HV P9: Avoid SPR scoreboard stalls
  KVM: PPC: Book3S HV P9: Only execute mtSPR if the value changed
  KVM: PPC: Book3S HV P9: Juggle SPR switching around
  KVM: PPC: Book3S HV P9: Move vcpu register save/restore into functions
  KVM: PPC: Book3S HV P9: Move host OS save/restore functions to
    built-in
  KVM: PPC: Book3S HV P9: Move nested guest entry into its own function
  KVM: PPC: Book3S HV P9: Move remaining SPR and MSR access into low
    level entry
  KVM: PPC: Book3S HV P9: Implement TM fastpath for guest entry/exit
  KVM: PPC: Book3S HV P9: Switch PMU to guest as late as possible
  KVM: PPC: Book3S HV P9: Restrict DSISR canary workaround to processors
    that require it
  KVM: PPC: Book3S HV P9: More SPR speed improvements
  KVM: PPC: Book3S HV P9: Demand fault EBB facility registers
  KVM: PPC: Book3S HV P9: Demand fault TM facility registers
  KVM: PPC: Book3S HV P9: Use Linux SPR save/restore to manage some host
    SPRs
  KVM: PPC: Book3S HV P9: Comment and fix MMU context switching code
  KVM: PPC: Book3S HV P9: Test dawr_enabled() before saving host DAWR
    SPRs
  KVM: PPC: Book3S HV P9: Don't restore PSSCR if not needed
  KVM: PPC: Book3S HV: Split P8 from P9 path guest vCPU TLB flushing
  KVM: PPC: Book3S HV P9: Avoid tlbsync sequence on radix guest exit
  KVM: PPC: Book3S HV Nested: Avoid extra mftb() in nested entry
  KVM: PPC: Book3S HV P9: Improve mfmsr performance on entry
  KVM: PPC: Book3S HV P9: Optimise hash guest SLB saving
  KVM: PPC: Book3S HV P9: Avoid changing MSR[RI] in entry and exit
  KVM: PPC: Book3S HV P9: Add unlikely annotation for !mmu_ready
  KVM: PPC: Book3S HV P9: Avoid cpu_in_guest atomics on entry and exit
  KVM: PPC: Book3S HV P9: Remove most of the vcore logic
  KVM: PPC: Book3S HV P9: Tidy kvmppc_create_dtl_entry
  KVM: PPC: Book3S HV P9: Stop using vc->dpdes
  KVM: PPC: Book3S HV P9: Remove subcore HMI handling

 .../admin-guide/kernel-parameters.txt         |   8 +
 arch/powerpc/include/asm/asm-prototypes.h     |   5 -
 arch/powerpc/include/asm/kvm_asm.h            |   1 +
 arch/powerpc/include/asm/kvm_book3s.h         |   6 +
 arch/powerpc/include/asm/kvm_book3s_64.h      |   5 +-
 arch/powerpc/include/asm/kvm_host.h           |   7 +-
 arch/powerpc/include/asm/kvm_ppc.h            |   4 +-
 arch/powerpc/include/asm/switch_to.h          |   3 +
 arch/powerpc/include/asm/time.h               |  19 +-
 arch/powerpc/kernel/cpu_setup_power.c         |  12 +-
 arch/powerpc/kernel/dt_cpu_ftrs.c             |   8 +-
 arch/powerpc/kernel/process.c                 |  34 +
 arch/powerpc/kernel/time.c                    |  54 +-
 arch/powerpc/kvm/Kconfig                      |  15 +
 arch/powerpc/kvm/book3s_64_entry.S            |  11 +-
 arch/powerpc/kvm/book3s_64_mmu_radix.c        |   4 +
 arch/powerpc/kvm/book3s_hv.c                  | 851 +++++++++--------
 arch/powerpc/kvm/book3s_hv.h                  |  42 +
 arch/powerpc/kvm/book3s_hv_builtin.c          |  55 +-
 arch/powerpc/kvm/book3s_hv_hmi.c              |   7 +-
 arch/powerpc/kvm/book3s_hv_interrupts.S       |  13 +-
 arch/powerpc/kvm/book3s_hv_nested.c           |   8 +-
 arch/powerpc/kvm/book3s_hv_p9_entry.c         | 898 +++++++++++++++---
 arch/powerpc/kvm/book3s_hv_ras.c              |  54 ++
 arch/powerpc/kvm/book3s_hv_rm_mmu.c           |   6 -
 arch/powerpc/kvm/book3s_hv_rmhandlers.S       |  73 +-
 arch/powerpc/mm/book3s64/radix_pgtable.c      |  15 -
 arch/powerpc/perf/core-book3s.c               |  35 +
 arch/powerpc/platforms/powernv/idle.c         |   9 +-
 arch/powerpc/xmon/xmon.c                      |  10 +-
 30 files changed, 1555 insertions(+), 717 deletions(-)
 create mode 100644 arch/powerpc/kvm/book3s_hv.h

-- 
2.23.0


^ permalink raw reply

* [PATCH v4 01/53] powerpc/64s: Remove WORT SPR from POWER9/10 (take 2)
From: Nicholas Piggin @ 2021-11-23  9:51 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20211123095231.1036501-1-npiggin@gmail.com>

This removes a missed remnant of the WORT SPR.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/platforms/powernv/idle.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/arch/powerpc/platforms/powernv/idle.c b/arch/powerpc/platforms/powernv/idle.c
index e3ffdc8e8567..86e787502e42 100644
--- a/arch/powerpc/platforms/powernv/idle.c
+++ b/arch/powerpc/platforms/powernv/idle.c
@@ -589,7 +589,6 @@ struct p9_sprs {
 	u64 purr;
 	u64 spurr;
 	u64 dscr;
-	u64 wort;
 	u64 ciabr;
 
 	u64 mmcra;
-- 
2.23.0


^ permalink raw reply related

* [PATCH v4 02/53] powerpc/64s: guard optional TIDR SPR with CPU ftr test
From: Nicholas Piggin @ 2021-11-23  9:51 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin, Fabiano Rosas
In-Reply-To: <20211123095231.1036501-1-npiggin@gmail.com>

The TIDR SPR only exists on POWER9. Avoid accessing it when the
feature bit for it is not set.

Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kvm/book3s_hv.c | 12 ++++++++----
 arch/powerpc/xmon/xmon.c     | 10 ++++++++--
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 7b74fc0a986b..2777f66001a8 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -3780,7 +3780,8 @@ static void load_spr_state(struct kvm_vcpu *vcpu)
 	mtspr(SPRN_EBBHR, vcpu->arch.ebbhr);
 	mtspr(SPRN_EBBRR, vcpu->arch.ebbrr);
 	mtspr(SPRN_BESCR, vcpu->arch.bescr);
-	mtspr(SPRN_TIDR, vcpu->arch.tid);
+	if (cpu_has_feature(CPU_FTR_P9_TIDR))
+		mtspr(SPRN_TIDR, vcpu->arch.tid);
 	mtspr(SPRN_AMR, vcpu->arch.amr);
 	mtspr(SPRN_UAMOR, vcpu->arch.uamor);
 
@@ -3806,7 +3807,8 @@ static void store_spr_state(struct kvm_vcpu *vcpu)
 	vcpu->arch.ebbhr = mfspr(SPRN_EBBHR);
 	vcpu->arch.ebbrr = mfspr(SPRN_EBBRR);
 	vcpu->arch.bescr = mfspr(SPRN_BESCR);
-	vcpu->arch.tid = mfspr(SPRN_TIDR);
+	if (cpu_has_feature(CPU_FTR_P9_TIDR))
+		vcpu->arch.tid = mfspr(SPRN_TIDR);
 	vcpu->arch.amr = mfspr(SPRN_AMR);
 	vcpu->arch.uamor = mfspr(SPRN_UAMOR);
 	vcpu->arch.dscr = mfspr(SPRN_DSCR);
@@ -3826,7 +3828,8 @@ struct p9_host_os_sprs {
 static void save_p9_host_os_sprs(struct p9_host_os_sprs *host_os_sprs)
 {
 	host_os_sprs->dscr = mfspr(SPRN_DSCR);
-	host_os_sprs->tidr = mfspr(SPRN_TIDR);
+	if (cpu_has_feature(CPU_FTR_P9_TIDR))
+		host_os_sprs->tidr = mfspr(SPRN_TIDR);
 	host_os_sprs->iamr = mfspr(SPRN_IAMR);
 	host_os_sprs->amr = mfspr(SPRN_AMR);
 	host_os_sprs->fscr = mfspr(SPRN_FSCR);
@@ -3840,7 +3843,8 @@ static void restore_p9_host_os_sprs(struct kvm_vcpu *vcpu,
 	mtspr(SPRN_UAMOR, 0);
 
 	mtspr(SPRN_DSCR, host_os_sprs->dscr);
-	mtspr(SPRN_TIDR, host_os_sprs->tidr);
+	if (cpu_has_feature(CPU_FTR_P9_TIDR))
+		mtspr(SPRN_TIDR, host_os_sprs->tidr);
 	mtspr(SPRN_IAMR, host_os_sprs->iamr);
 
 	if (host_os_sprs->amr != vcpu->arch.amr)
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 8b28ff9d98d1..83100c6524cc 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2107,8 +2107,14 @@ static void dump_300_sprs(void)
 	if (!cpu_has_feature(CPU_FTR_ARCH_300))
 		return;
 
-	printf("pidr   = %.16lx  tidr  = %.16lx\n",
-		mfspr(SPRN_PID), mfspr(SPRN_TIDR));
+	if (cpu_has_feature(CPU_FTR_P9_TIDR)) {
+		printf("pidr   = %.16lx  tidr  = %.16lx\n",
+			mfspr(SPRN_PID), mfspr(SPRN_TIDR));
+	} else {
+		printf("pidr   = %.16lx\n",
+			mfspr(SPRN_PID));
+	}
+
 	printf("psscr  = %.16lx\n",
 		hv ? mfspr(SPRN_PSSCR) : mfspr(SPRN_PSSCR_PR));
 
-- 
2.23.0


^ permalink raw reply related

* [PATCH v4 03/53] KMV: PPC: Book3S HV P9: Use set_dec to set decrementer to host
From: Nicholas Piggin @ 2021-11-23  9:51 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Alexey Kardashevskiy, Nicholas Piggin
In-Reply-To: <20211123095231.1036501-1-npiggin@gmail.com>

The host Linux timer code arms the decrementer with the value
'decrementers_next_tb - current_tb' using set_dec(), which stores
val - 1 on Book3S-64, which is not quite the same as what KVM does
to re-arm the host decrementer when exiting the guest.

This shouldn't be a significant change, but it makes the logic match
and avoids this small extra change being brought into the next patch.

Suggested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kvm/book3s_hv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 2777f66001a8..c7dbdec183b9 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -4063,7 +4063,7 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
 	vc->entry_exit_map = 0x101;
 	vc->in_guest = 0;
 
-	mtspr(SPRN_DEC, local_paca->kvm_hstate.dec_expires - mftb());
+	set_dec(local_paca->kvm_hstate.dec_expires - mftb());
 	/* We may have raced with new irq work */
 	if (test_irq_work_pending())
 		set_dec(1);
-- 
2.23.0


^ permalink raw reply related

* [PATCH v4 04/53] KVM: PPC: Book3S HV P9: Use host timer accounting to avoid decrementer read
From: Nicholas Piggin @ 2021-11-23  9:51 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin
In-Reply-To: <20211123095231.1036501-1-npiggin@gmail.com>

There is no need to save away the host DEC value, as it is derived
from the host timer subsystem which maintains the next timer time,
so it can be restored from there.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/include/asm/time.h |  5 +++++
 arch/powerpc/kernel/time.c      |  1 +
 arch/powerpc/kvm/book3s_hv.c    | 14 +++++++-------
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h
index 8c2c3dd4ddba..fd09b4797fd7 100644
--- a/arch/powerpc/include/asm/time.h
+++ b/arch/powerpc/include/asm/time.h
@@ -111,6 +111,11 @@ static inline unsigned long test_irq_work_pending(void)
 
 DECLARE_PER_CPU(u64, decrementers_next_tb);
 
+static inline u64 timer_get_next_tb(void)
+{
+	return __this_cpu_read(decrementers_next_tb);
+}
+
 /* Convert timebase ticks to nanoseconds */
 unsigned long long tb_to_ns(unsigned long long tb_ticks);
 
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index cae8f03a44fe..374950afec2f 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -107,6 +107,7 @@ struct clock_event_device decrementer_clockevent = {
 EXPORT_SYMBOL(decrementer_clockevent);
 
 DEFINE_PER_CPU(u64, decrementers_next_tb);
+EXPORT_SYMBOL_GPL(decrementers_next_tb);
 static DEFINE_PER_CPU(struct clock_event_device, decrementers);
 
 #define XSEC_PER_SEC (1024*1024)
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index c7dbdec183b9..3322edbafc64 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -3873,18 +3873,17 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
 	struct kvmppc_vcore *vc = vcpu->arch.vcore;
 	struct p9_host_os_sprs host_os_sprs;
 	s64 dec;
-	u64 tb;
+	u64 tb, next_timer;
 	int trap, save_pmu;
 
 	WARN_ON_ONCE(vcpu->arch.ceded);
 
-	dec = mfspr(SPRN_DEC);
 	tb = mftb();
-	if (dec < 0)
+	next_timer = timer_get_next_tb();
+	if (tb >= next_timer)
 		return BOOK3S_INTERRUPT_HV_DECREMENTER;
-	local_paca->kvm_hstate.dec_expires = dec + tb;
-	if (local_paca->kvm_hstate.dec_expires < time_limit)
-		time_limit = local_paca->kvm_hstate.dec_expires;
+	if (next_timer < time_limit)
+		time_limit = next_timer;
 
 	save_p9_host_os_sprs(&host_os_sprs);
 
@@ -4063,7 +4062,8 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
 	vc->entry_exit_map = 0x101;
 	vc->in_guest = 0;
 
-	set_dec(local_paca->kvm_hstate.dec_expires - mftb());
+	next_timer = timer_get_next_tb();
+	set_dec(next_timer - mftb());
 	/* We may have raced with new irq work */
 	if (test_irq_work_pending())
 		set_dec(1);
-- 
2.23.0


^ permalink raw reply related

* [PATCH v4 05/53] KVM: PPC: Book3S HV P9: Use large decrementer for HDEC
From: Nicholas Piggin @ 2021-11-23  9:51 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Alexey Kardashevskiy, Nicholas Piggin
In-Reply-To: <20211123095231.1036501-1-npiggin@gmail.com>

On processors that don't suppress the HDEC exceptions when LPCR[HDICE]=0,
this could help reduce needless guest exits due to leftover exceptions on
entering the guest.

Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/include/asm/time.h       | 2 ++
 arch/powerpc/kernel/time.c            | 1 +
 arch/powerpc/kvm/book3s_hv_p9_entry.c | 3 ++-
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/time.h b/arch/powerpc/include/asm/time.h
index fd09b4797fd7..69b6be617772 100644
--- a/arch/powerpc/include/asm/time.h
+++ b/arch/powerpc/include/asm/time.h
@@ -18,6 +18,8 @@
 #include <asm/vdso/timebase.h>
 
 /* time.c */
+extern u64 decrementer_max;
+
 extern unsigned long tb_ticks_per_jiffy;
 extern unsigned long tb_ticks_per_usec;
 extern unsigned long tb_ticks_per_sec;
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 374950afec2f..2769d565f842 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -88,6 +88,7 @@ static struct clocksource clocksource_timebase = {
 
 #define DECREMENTER_DEFAULT_MAX 0x7FFFFFFF
 u64 decrementer_max = DECREMENTER_DEFAULT_MAX;
+EXPORT_SYMBOL_GPL(decrementer_max); /* for KVM HDEC */
 
 static int decrementer_set_next_event(unsigned long evt,
 				      struct clock_event_device *dev);
diff --git a/arch/powerpc/kvm/book3s_hv_p9_entry.c b/arch/powerpc/kvm/book3s_hv_p9_entry.c
index 961b3d70483c..0ff9ddb5e7ca 100644
--- a/arch/powerpc/kvm/book3s_hv_p9_entry.c
+++ b/arch/powerpc/kvm/book3s_hv_p9_entry.c
@@ -504,7 +504,8 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 time_limit, unsigned long lpc
 		vc->tb_offset_applied = 0;
 	}
 
-	mtspr(SPRN_HDEC, 0x7fffffff);
+	/* HDEC must be at least as large as DEC, so decrementer_max fits */
+	mtspr(SPRN_HDEC, decrementer_max);
 
 	save_clear_guest_mmu(kvm, vcpu);
 	switch_mmu_to_host(kvm, host_pidr);
-- 
2.23.0


^ permalink raw reply related

* [PATCH v4 06/53] KVM: PPC: Book3S HV P9: Reduce mftb per guest entry/exit
From: Nicholas Piggin @ 2021-11-23  9:51 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Nicholas Piggin, Fabiano Rosas
In-Reply-To: <20211123095231.1036501-1-npiggin@gmail.com>

mftb is serialising (dispatch next-to-complete) so it is heavy weight
for a mfspr. Avoid reading it multiple times in the entry or exit paths.
A small number of cycles delay to timers is tolerable.

Reviewed-by: Fabiano Rosas <farosas@linux.ibm.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 arch/powerpc/kvm/book3s_hv.c          | 4 ++--
 arch/powerpc/kvm/book3s_hv_p9_entry.c | 5 +++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
index 3322edbafc64..5fc0c168a39a 100644
--- a/arch/powerpc/kvm/book3s_hv.c
+++ b/arch/powerpc/kvm/book3s_hv.c
@@ -3940,7 +3940,7 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
 	 *
 	 * XXX: Another day's problem.
 	 */
-	mtspr(SPRN_DEC, vcpu->arch.dec_expires - mftb());
+	mtspr(SPRN_DEC, vcpu->arch.dec_expires - tb);
 
 	if (kvmhv_on_pseries()) {
 		/*
@@ -4063,7 +4063,7 @@ static int kvmhv_p9_guest_entry(struct kvm_vcpu *vcpu, u64 time_limit,
 	vc->in_guest = 0;
 
 	next_timer = timer_get_next_tb();
-	set_dec(next_timer - mftb());
+	set_dec(next_timer - tb);
 	/* We may have raced with new irq work */
 	if (test_irq_work_pending())
 		set_dec(1);
diff --git a/arch/powerpc/kvm/book3s_hv_p9_entry.c b/arch/powerpc/kvm/book3s_hv_p9_entry.c
index 0ff9ddb5e7ca..bd8cf0a65ce8 100644
--- a/arch/powerpc/kvm/book3s_hv_p9_entry.c
+++ b/arch/powerpc/kvm/book3s_hv_p9_entry.c
@@ -203,7 +203,8 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 time_limit, unsigned long lpc
 	unsigned long host_dawr1;
 	unsigned long host_dawrx1;
 
-	hdec = time_limit - mftb();
+	tb = mftb();
+	hdec = time_limit - tb;
 	if (hdec < 0)
 		return BOOK3S_INTERRUPT_HV_DECREMENTER;
 
@@ -215,7 +216,7 @@ int kvmhv_vcpu_entry_p9(struct kvm_vcpu *vcpu, u64 time_limit, unsigned long lpc
 	vcpu->arch.ceded = 0;
 
 	if (vc->tb_offset) {
-		u64 new_tb = mftb() + vc->tb_offset;
+		u64 new_tb = tb + vc->tb_offset;
 		mtspr(SPRN_TBU40, new_tb);
 		tb = mftb();
 		if ((tb & 0xffffff) < (new_tb & 0xffffff))
-- 
2.23.0


^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox