LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v8 0/7] powerpc/perf: Add json file metric support for the hv_24x7 socket/chip level events
From: Arnaldo Carvalho de Melo @ 2020-04-29 14:46 UTC (permalink / raw)
  To: kajoljain
  Cc: mark.rutland, maddy, peterz, yao.jin, mingo, kan.liang, ak,
	alexander.shishkin, anju, mamatha4, sukadev, ravi.bangoria,
	jmario, namhyung, tglx, mpetlan, gregkh, linux-kernel,
	linux-perf-users, jolsa, linuxppc-dev
In-Reply-To: <fa31bc42-d34c-c788-0109-350d769b51ce@linux.ibm.com>

Em Tue, Apr 28, 2020 at 12:02:42PM +0530, kajoljain escreveu:
> Hi Arnaldo,
> 	Please let me know if there any changes required in this patchset,
> as some of its patches are still not part of your perf/core tree.

Thanks, I checked and all seems ok, added Jiri's Acked-by, appreciated,
thanks,

- Arnaldo
 
> Thanks,
> Kajol Jain
> 
> On 4/2/20 2:03 AM, Kajol Jain wrote:
> > Patchset adds json file metric support for the hv_24x7 socket/chip level
> > events. "hv_24x7" pmu interface events needs system dependent parameter
> > like socket/chip/core. For example, hv_24x7 chip level events needs
> > specific chip-id to which the data is requested should be added as part
> > of pmu events.
> > 
> > So to enable JSON file support to "hv_24x7" interface, patchset reads
> > total number of sockets details in sysfs under 
> > "/sys/devices/hv_24x7/interface/".
> > 
> > Second patch of the patchset adds expr_scanner_ctx object to hold user
> > data for the expr scanner, which can be used to hold runtime parameter.
> > 
> > Patch 4 & 6 of the patchset handles perf tool plumbing needed to replace
> > the "?" character in the metric expression to proper value and hv_24x7
> > json metric file for different Socket/chip resources.
> > 
> > Patch set also enable Hz/hz prinitg for --metric-only option to print
> > metric data for bus frequency.
> > 
> > Applied and tested all these patches cleanly on top of jiri's flex changes
> > with the changes done by Kan Liang for "Support metric group constraint"
> > patchset and made required changes.
> > 
> > Also apply this patch on top of the fix patch send earlier
> > for printing metric name incase overlapping events.
> > https://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git/commit/?h=perf/core&id=37cd7f65bf71a48f25eeb6d9be5dacb20d008ea6
> > 
> > Changelog:
> > v7 -> v8
> > - Add test case for testing parsing of "?" in metric expression
> > - Reaname variables name to runtime
> > 
> > v6 -> v7
> > - Spit patchset into two patch series one for kernel changes and other
> >   for tool side changes.
> > - Made changes Suggested by Jiri, including rather then reading runtime
> >   parameter from metric name, actually add it in structure egroup and
> >   metric_expr.
> > - As we don't need to read runtime parameter from metric name,
> >   now I am not appending it and rather just printing it in
> >   generic_metric function.
> > 
> > Kernel Side changes patch series: https://lkml.org/lkml/2020/3/27/58
> > 
> > v5 -> v6
> > - resolve compilation issue due to rearranging patch series.
> > - Rather then adding new function to take careof case for runtime param
> >   in metricgroup__add_metric, using metricgroup__add_metric_param itself
> >   for that work.
> > - Address some optimization suggested like using directly file path
> >   rather then adding new macro in header.c
> > - Change commit message on patch where we are adding "?" support
> >   by adding simple example.
> > 
> > v4 -> v5
> > - Using sysfs__read_int instead of sysfs__read_ull while reading
> >   parameter value in powerpc/util/header.c file.
> > 
> > - Using asprintf rather then malloc and sprintf 
> >   Suggested by Arnaldo Carvalho de Melo
> > 
> > - Break patch 6 from previous version to two patch,
> >   - One to add refactor current "metricgroup__add_metric" function
> >     and another where actually "?" handling infra added.
> > 
> > - Add expr__runtimeparam as part of 'expr_scanner_ctx' struct
> >   rather then making it global variable. Thanks Jiri for
> >   adding this structure to hold user data for the expr scanner.
> > 
> > - Add runtime param as agrugement to function 'expr__find_other'
> >   and 'expr__parse' and made changes on references accordingly.
> > 
> > v3 -> v4
> > - Apply these patch on top of Kan liang changes.
> >   As suggested by Jiri.
> > 
> > v2 -> v3
> > - Remove setting  event_count to 0 part in function 'h_24x7_event_read'
> >   with comment rather then adding 0 to event_count value.
> >   Suggested by: Sukadev Bhattiprolu
> > 
> > - Apply tool side changes require to replace "?" on Jiri's flex patch
> >   series and made all require changes to make it compatible with added
> >   flex change.
> > 
> > v1 -> v2
> > - Rename hv-24x7 metric json file as nest_metrics.json
> > 
> > Jiri Olsa (2):
> >   perf expr: Add expr_ prefix for parse_ctx and parse_id
> >   perf expr: Add expr_scanner_ctx object
> > 
> > Kajol Jain (5):
> >   perf/tools: Refactoring metricgroup__add_metric function
> >   perf/tools: Enhance JSON/metric infrastructure to handle "?"
> >   perf/tests/expr: Added test for runtime param in metric expression
> >   tools/perf: Enable Hz/hz prinitg for --metric-only option
> >   perf/tools/pmu-events/powerpc: Add hv_24x7 socket/chip level metric
> >     events
> > 
> >  tools/perf/arch/powerpc/util/header.c         |  8 ++
> >  .../arch/powerpc/power9/nest_metrics.json     | 19 +++++
> >  tools/perf/tests/expr.c                       | 20 +++--
> >  tools/perf/util/expr.c                        | 25 +++---
> >  tools/perf/util/expr.h                        | 19 +++--
> >  tools/perf/util/expr.l                        | 37 ++++++---
> >  tools/perf/util/expr.y                        |  6 +-
> >  tools/perf/util/metricgroup.c                 | 78 +++++++++++++------
> >  tools/perf/util/metricgroup.h                 |  2 +
> >  tools/perf/util/stat-display.c                |  2 -
> >  tools/perf/util/stat-shadow.c                 | 19 +++--
> >  11 files changed, 164 insertions(+), 71 deletions(-)
> >  create mode 100644 tools/perf/pmu-events/arch/powerpc/power9/nest_metrics.json
> > 

-- 

- Arnaldo

^ permalink raw reply

* Re: [PATCH v2 16/20] mm: remove early_pfn_in_nid() and CONFIG_NODES_SPAN_OTHER_NODES
From: Mike Rapoport @ 2020-04-29 14:33 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
	Heiko Carstens, x86, Michal Hocko, James E.J. Bottomley,
	Max Filippov, Guo Ren, Ley Foon Tan, sparclinux, linux-riscv,
	Greg Ungerer, linux-arch, linux-s390, linux-c6x-dev, Baoquan He,
	Jonathan Corbet, linux-hexagon, Helge Deller, linux-sh,
	Russell King, linux-csky, Mike Rapoport, Geert Uytterhoeven,
	Hoan Tran, Mark Salter, Matt Turner, linux-snps-arc,
	uclinux-h8-devel, linux-xtensa, Nick Hu, linux-um, linux-mips,
	Richard Weinberger, linux-m68k, Thomas Bogendoerfer, Qian Cai,
	Greentime Hu, Paul Walmsley, Stafford Horne, Guan Xuetao,
	linux-arm-kernel, Michal Simek, Tony Luck, Yoshinori Sato,
	linux-parisc, linux-mm, Vineet Gupta, Brian Cain, linux-kernel,
	openrisc, linux-alpha, Andrew Morton, linuxppc-dev,
	David S. Miller
In-Reply-To: <20200429141706.GA25142@infradead.org>

On Wed, Apr 29, 2020 at 07:17:06AM -0700, Christoph Hellwig wrote:
> On Wed, Apr 29, 2020 at 03:11:22PM +0300, Mike Rapoport wrote:
> > From: Mike Rapoport <rppt@linux.ibm.com>
> > 
> > The commit f47ac088c406 ("mm: memmap_init: iterate over memblock regions
> > rather that check each PFN") made early_pfn_in_nid() obsolete and since
> > CONFIG_NODES_SPAN_OTHER_NODES is only used to pick a stub or a real
> > implementation of early_pfn_in_nid() it is also not needed anymore.
> 
> I don't think you can quote a commit id for something that hasn't been
> commited to mainline yet.i

Ouch, that was one of the things I've indented to fix in v2...

> Then again I would have just merged this
> patch into the one that obsoleted early_pfn_in_nid anyway.

I've kept these commits separate to preserve the authorship.
I'll update the changelog so that it won't mention commit id.

-- 
Sincerely yours,
Mike.

^ permalink raw reply

* Re: [PATCH v2 16/20] mm: remove early_pfn_in_nid() and CONFIG_NODES_SPAN_OTHER_NODES
From: Christoph Hellwig @ 2020-04-29 14:17 UTC (permalink / raw)
  To: Mike Rapoport
  Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
	Heiko Carstens, x86, Michal Hocko, James E.J. Bottomley,
	Max Filippov, Guo Ren, Ley Foon Tan, sparclinux, linux-riscv,
	Greg Ungerer, linux-arch, linux-s390, linux-c6x-dev, Baoquan He,
	Jonathan Corbet, linux-hexagon, Helge Deller, linux-sh,
	Russell King, linux-csky, Mike Rapoport, Geert Uytterhoeven,
	Hoan Tran, Mark Salter, Matt Turner, linux-snps-arc,
	uclinux-h8-devel, linux-xtensa, Nick Hu, linux-um, linux-mips,
	Richard Weinberger, linux-m68k, Thomas Bogendoerfer, Qian Cai,
	Greentime Hu, Paul Walmsley, Stafford Horne, Guan Xuetao,
	linux-arm-kernel, Michal Simek, Tony Luck, Yoshinori Sato,
	linux-parisc, linux-mm, Vineet Gupta, Brian Cain, linux-kernel,
	openrisc, linux-alpha, Andrew Morton, linuxppc-dev,
	David S. Miller
In-Reply-To: <20200429121126.17989-17-rppt@kernel.org>

On Wed, Apr 29, 2020 at 03:11:22PM +0300, Mike Rapoport wrote:
> From: Mike Rapoport <rppt@linux.ibm.com>
> 
> The commit f47ac088c406 ("mm: memmap_init: iterate over memblock regions
> rather that check each PFN") made early_pfn_in_nid() obsolete and since
> CONFIG_NODES_SPAN_OTHER_NODES is only used to pick a stub or a real
> implementation of early_pfn_in_nid() it is also not needed anymore.

I don't think you can quote a commit id for something that hasn't been
commited to mainline yet.  Then again I would have just merged this
patch into the one that obsoleted early_pfn_in_nid anyway.

^ permalink raw reply

* Re: [RFC PATCH v2 7/7] powerpc/selftest: reuse ppc-opcode macros to avoid redundancy
From: Naveen N. Rao @ 2020-04-29 14:17 UTC (permalink / raw)
  To: Balamuruhan S, Michael Ellerman
  Cc: ravi.bangoria, jniethe5, paulus, sandipan, linuxppc-dev
In-Reply-To: <87k11yfvxu.fsf@mpe.ellerman.id.au>

Michael Ellerman wrote:
> Balamuruhan S <bala24@linux.ibm.com> writes:
>> Avoid redefining macros to encode ppc instructions instead reuse it from
>> ppc-opcode.h, Makefile changes are necessary to compile memcmp_64.S with
>> __ASSEMBLY__ defined from selftests.
>>
>> Signed-off-by: Balamuruhan S <bala24@linux.ibm.com>
>> ---
>>  .../selftests/powerpc/stringloops/Makefile    | 34 ++++++++++++++----
>>  .../powerpc/stringloops/asm/asm-const.h       |  1 +
>>  .../powerpc/stringloops/asm/ppc-opcode.h      | 36 +------------------
>>  3 files changed, 29 insertions(+), 42 deletions(-)
>>  create mode 120000 tools/testing/selftests/powerpc/stringloops/asm/asm-const.h
>>  mode change 100644 => 120000 tools/testing/selftests/powerpc/stringloops/asm/ppc-opcode.h
>>
>> diff --git a/tools/testing/selftests/powerpc/stringloops/Makefile b/tools/testing/selftests/powerpc/stringloops/Makefile
>> index 7fc0623d85c3..efe76c5a5b94 100644
>> --- a/tools/testing/selftests/powerpc/stringloops/Makefile
>> +++ b/tools/testing/selftests/powerpc/stringloops/Makefile
>> @@ -1,26 +1,44 @@
>>  # SPDX-License-Identifier: GPL-2.0
>>  # The loops are all 64-bit code
>> -CFLAGS += -I$(CURDIR)
>> +GIT_VERSION = $(shell git describe --always --long --dirty || echo "unknown")
>> +CFLAGS += -DGIT_VERSION='"$(GIT_VERSION)"' -I$(CURDIR) -I$(CURDIR)/../include
>>  
>>  EXTRA_SOURCES := ../harness.c
>>  
>>  build_32bit = $(shell if ($(CC) $(CFLAGS) -m32 -o /dev/null memcmp.c >/dev/null 2>&1) then echo "1"; fi)
>>  
>> +ifneq ($(build_32bit),1)
>>  TEST_GEN_PROGS := memcmp_64 strlen
>> +TEST_GEN_FILES := memcmp.o memcmp_64.o memcmp_64
>> +MEMCMP := $(OUTPUT)/memcmp.o
>> +MEMCMP_64 := $(OUTPUT)/memcmp_64.o
>> +HARNESS :=  $(OUTPUT)/../harness.o
>> +CFLAGS += -m64 -maltivec
>>  
>> -$(OUTPUT)/memcmp_64: memcmp.c
>> -$(OUTPUT)/memcmp_64: CFLAGS += -m64 -maltivec
>> +OVERRIDE_TARGETS := 1
>> +include ../../lib.mk
>>  
>> -ifeq ($(build_32bit),1)
>> +$(OUTPUT)/memcmp_64: $(MEMCMP_64) $(MEMCMP) $(HARNESS)
>> +	$(CC) $(CFLAGS) memcmp.o memcmp_64.o ../harness.o -o memcmp_64
>> +
>> +$(MEMCMP_64): memcmp_64.S
>> +	$(CC) $(CFLAGS) -D__ASSEMBLY__ -o memcmp_64.o -c memcmp_64.S
>> +
>> +$(MEMCMP): memcmp.c
>> +	$(CC) $(CFLAGS) -o memcmp.o -c memcmp.c
>> +
>> +$(HARNESS): $(EXTRA_SOURCES)
>> +	$(CC) $(CFLAGS) -DGIT_VERSION='"$(GIT_VERSION)"' -o ../harness.o -c $(EXTRA_SOURCES)
> 
> What are you actually trying to do here? Is it just that you need to
> define __ASSEMBLY__ for memcmp_64.S?

Adding __ASSEMBLY__ while building memcmp_64.S would be the goal, so as 
to reuse ppc-opcode.h. However, asm/ppc-opcode.h under stringloops test 
is tiny and doesn't seem to justify the change.

> 
> What you have breaks the build, it's not respecting $(OUTPUT).

I think we should just drop this patch from the series.

Bala,
Can you re-post this series without the RFC tag, with the last patch 
dropped?


- Naveen


^ permalink raw reply

* Re: [PATCH] ASoC: fsl_easrc: Check NULL pinter before dereference
From: Mark Brown @ 2020-04-29 14:14 UTC (permalink / raw)
  To: Shengjiu Wang
  Cc: alsa-devel, timur, Xiubo.Lee, linuxppc-dev, tiwai, lgirdwood,
	perex, nicoleotsuka, festevam, linux-kernel
In-Reply-To: <1587731404-29750-1-git-send-email-shengjiu.wang@nxp.com>

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

On Fri, Apr 24, 2020 at 08:30:04PM +0800, Shengjiu Wang wrote:
> The patch 955ac624058f: "ASoC: fsl_easrc: Add EASRC ASoC CPU DAI
> drivers" from Apr 16, 2020, leads to the following Smatch complaint:

This doesn't apply against current code, please check and resend.

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

^ permalink raw reply

* Re: [Skiboot] [PATCH v8 3/3] Self save API integration
From: Vaidyanathan Srinivasan @ 2020-04-29 14:08 UTC (permalink / raw)
  To: Pratik Rajesh Sampat
  Cc: ego, pratik.r.sampat, linuxram, linux-kernel, linuxppc-dev,
	oohall, skiboot
In-Reply-To: <20200423105438.29034-4-psampat@linux.ibm.com>

* Pratik Rajesh Sampat <psampat@linux.ibm.com> [2020-04-23 16:24:38]:

> The commit makes the self save API available outside the firmware by defining
> an OPAL wrapper.
> This wrapper has a similar interface to that of self restore and expects the
> cpu pir, SPR number, minus the value of that SPR to be passed in its
> paramters and returns OPAL_SUCCESS on success. It adds a device-tree
> node signifying support for self-save after verifying the stop API
> version compatibility.
> 
> The commit also documents both the self-save and the self-restore API
> calls along with their working and usage.
> 
> Signed-off-by: Pratik Rajesh Sampat <psampat@linux.ibm.com>

Reviewed-by: Vaidyanathan Srinivasan <svaidy@linux.ibm.com>

> ---
>  doc/opal-api/opal-slw-self-save-reg-181.rst |  51 ++++++++++
>  doc/opal-api/opal-slw-set-reg-100.rst       |   5 +
>  doc/power-management.rst                    |  48 +++++++++
>  hw/slw.c                                    | 106 ++++++++++++++++++++
>  include/opal-api.h                          |   3 +-
>  include/p9_stop_api.H                       |  18 ++++
>  include/skiboot.h                           |   3 +
>  7 files changed, 233 insertions(+), 1 deletion(-)
>  create mode 100644 doc/opal-api/opal-slw-self-save-reg-181.rst

This patch enables OPAL interface to call stop-api and set self-save.
Basically completes the infrastructure required to use the new
self-save function provided by the microcode.

--Vaidy

^ permalink raw reply

* Re: [PATCH v8 2/3] API to verify the STOP API and image compatibility
From: Vaidyanathan Srinivasan @ 2020-04-29 14:05 UTC (permalink / raw)
  To: Pratik Rajesh Sampat
  Cc: ego, pratik.r.sampat, linuxram, linux-kernel, linuxppc-dev,
	oohall, skiboot
In-Reply-To: <20200423105438.29034-3-psampat@linux.ibm.com>

* Pratik Rajesh Sampat <psampat@linux.ibm.com> [2020-04-23 16:24:37]:

> From: Prem Shanker Jha <premjha2@in.ibm.com>
> 
> Commit defines a new API primarily intended for OPAL to determine
> cpu register save API's compatibility with HOMER layout and
> self save restore. It can help OPAL determine if version of
> API integrated with OPAL is different from hostboot.
> 
> Change-Id: Ic0de45a336cfb8b6b6096a10ac1cd3ffbaa44fc0
> Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/77612
> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
> Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
> Reviewed-by: RANGANATHPRASAD G. BRAHMASAMUDRA <prasadbgr@in.ibm.com>
> Reviewed-by: Gregory S Still <stillgs@us.ibm.com>
> Reviewed-by: Jennifer A Stofer <stofer@us.ibm.com>
> Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/77614
> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
> Reviewed-by: Daniel M Crowell <dcrowell@us.ibm.com>
> Signed-off-by: Pratik Rajesh Sampat <psampat@linux.ibm.com>

Reviewed-by: Vaidyanathan Srinivasan <svaidy@linux.ibm.com>

> ---
>  include/p9_stop_api.H                    | 25 ++++++++++
>  libpore/p9_cpu_reg_restore_instruction.H |  7 ++-
>  libpore/p9_hcd_memmap_base.H             |  7 +++
>  libpore/p9_stop_api.C                    | 58 +++++++++++++++++++++++-
>  libpore/p9_stop_api.H                    | 26 ++++++++++-
>  libpore/p9_stop_util.H                   | 20 ++++----
>  6 files changed, 130 insertions(+), 13 deletions(-)

This stop-api code will help OPAL check and use self-save functions so
that different versions of OPAL can be loaded and run with different
versions of low level firmware stack.

--Vaidy

^ permalink raw reply

* Re: [Skiboot] [PATCH v8 1/3] Self Save: Introducing Support for SPR Self Save
From: Vaidyanathan Srinivasan @ 2020-04-29 14:02 UTC (permalink / raw)
  To: Pratik Rajesh Sampat
  Cc: ego, pratik.r.sampat, linuxram, linux-kernel, linuxppc-dev,
	oohall, skiboot
In-Reply-To: <20200423105438.29034-2-psampat@linux.ibm.com>

* Pratik Rajesh Sampat <psampat@linux.ibm.com> [2020-04-23 16:24:36]:

> From: Prem Shanker Jha <premjha2@in.ibm.com>
> 
> The commit is a merger of commits that makes the following changes:
> 1. Commit fixes some issues with code found during integration test
>   -  replacement of addi with xor instruction during self save API.
>   -  fixing instruction generation for MFMSR during self save
>   -  data struct updates in STOP API
>   -  error RC updates for hcode image build
>   -  HOMER parser updates.
>   -  removed self save support for URMOR and HRMOR
>   -  code changes for compilation with OPAL
>   -  populating CME Image header with unsecure HOMER address.
> 
> Key_Cronus_Test=PM_REGRESS
> 
> Change-Id: I7cedcc466267c4245255d8d75c01ed695e316720
> Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/66580
> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
> Tested-by: HWSV CI <hwsv-ci+hostboot@us.ibm.com>
> Tested-by: PPE CI <ppe-ci+hostboot@us.ibm.com>
> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
> Tested-by: Cronus HW CI <cronushw-ci+hostboot@us.ibm.com>
> Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
> Reviewed-by: Gregory S. Still <stillgs@us.ibm.com>
> Reviewed-by: RAHUL BATRA <rbatra@us.ibm.com>
> Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
> Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/66587
> Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
> Signed-off-by: Prem Shanker Jha <premjha2@in.ibm.com>
> Signed-off-by: Akshay Adiga <akshay.adiga@linux.vnet.ibm.com>
> Signed-off-by: Pratik Rajesh Sampat <psampat@linux.ibm.com>

Reviewed-by: Vaidyanathan Srinivasan <svaidy@linux.ibm.com>

> 2. The commit also incorporates changes that make STOP API project
> agnostic changes include defining wrapper functions which call legacy
> API. It also adds duplicate enum members which start with prefix PROC
> instead of P9.
> 
> Key_Cronus_Test=PM_REGRESS
> 
> Change-Id: If87970f3e8cf9b507f33eb1be249e03eb3836a5e
> RTC: 201128
> Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/71307
> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
> Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
> Tested-by: Cronus HW CI <cronushw-ci+hostboot@us.ibm.com>
> Reviewed-by: RANGANATHPRASAD G. BRAHMASAMUDRA <prasadbgr@in.ibm.com>
> Reviewed-by: Gregory S. Still <stillgs@us.ibm.com>
> Reviewed-by: Jennifer A Stofer <stofer@us.ibm.com>
> Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/71314
> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
> Signed-off-by: Prem Shanker Jha <premjha2@in.ibm.com>
> Signed-off-by: Pratik Rajesh Sampat <psampat@linux.ibm.com>
> ---
>  include/p9_stop_api.H                    |  79 +-
>  libpore/p9_cpu_reg_restore_instruction.H |   4 +
>  libpore/p9_stop_api.C                    | 954 +++++++++++++----------
>  libpore/p9_stop_api.H                    | 115 ++-
>  libpore/p9_stop_data_struct.H            |   4 +-
>  libpore/p9_stop_util.H                   |   7 +-
>  6 files changed, 721 insertions(+), 442 deletions(-)


These code changes are from hcode component copied as is into OPAL
project for integration and use of stop-api.

Hcode component in cooperation with hostboot would be loaded in memory
before OPAL is loaded. This code will allow runtime changes and usage
of various power management save restore functions.

This patch specifically enables self-save feature by the microcode.

--Vaidy


^ permalink raw reply

* Re: [RFC PATCH dpss_eth] Don't initialise ports with no PHY
From: Andrew Lunn @ 2020-04-29 13:12 UTC (permalink / raw)
  To: Christian Zigotzky
  Cc: madalin.bacur, R.T.Dickinson, netdev, oss, Darren Stevens,
	contact@a-eon.com, mad skateman, linuxppc-dev
In-Reply-To: <ca95a1b2-1b16-008c-18ba-2cbd79f240e6@xenosoft.de>

> Maybe we have to modify the dtb file.

Hi Christian

Could you point me at the DT file.

      Thanks
	Andrew

^ permalink raw reply

* Re: [PATCH] fixup! signal: factor copy_siginfo_to_external32 from copy_siginfo_to_user32
From: Arnd Bergmann @ 2020-04-29 12:34 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jeremy Kerr, linux-kernel@vger.kernel.org, Eric W . Biederman,
	Linux FS-devel Mailing List, Andrew Morton, linuxppc-dev,
	Alexander Viro
In-Reply-To: <20200429115316.GA7886@lst.de>

On Wed, Apr 29, 2020 at 1:53 PM Christoph Hellwig <hch@lst.de> wrote:
>
> I did another pass at this, reducing the overhead of the x32 magic
> in common code down to renaming copy_siginfo_to_user32 to
> copy_siginfo_to_user32 and having a conditional #define to give it
> the old name back:

Nice! I guess this is about as good as it gets, so we can stop
spending more time on it now ;-)

       Arnd

^ permalink raw reply

* Re: [PATCH v4 4/7] KVM: PPC: clean up redundant 'kvm_run' parameters
From: Vitaly Kuznetsov @ 2020-04-29 12:32 UTC (permalink / raw)
  To: Tianjia Zhang
  Cc: christoffer.dall, wanpengli, kvm, david, heiko.carstens, peterx,
	linux-kernel, hpa, kvmarm, linux-s390, frankja, chenhuacai, joro,
	x86, borntraeger, mingo, julien.thierry.kdev, thuth, gor,
	suzuki.poulose, kvm-ppc, bp, tglx, linux-arm-kernel, jmattson,
	tsbogend, tianjia.zhang, cohuck, linux-mips,
	sean.j.christopherson, james.morse, maz, pbonzini, linuxppc-dev
In-Reply-To: <20200427043514.16144-5-tianjia.zhang@linux.alibaba.com>

Tianjia Zhang <tianjia.zhang@linux.alibaba.com> writes:

> In the current kvm version, 'kvm_run' has been included in the 'kvm_vcpu'
> structure. For historical reasons, many kvm-related function parameters
> retain the 'kvm_run' and 'kvm_vcpu' parameters at the same time. This
> patch does a unified cleanup of these remaining redundant parameters.
>
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> ---
>  arch/powerpc/include/asm/kvm_book3s.h    | 16 +++---
>  arch/powerpc/include/asm/kvm_ppc.h       | 27 +++++----
>  arch/powerpc/kvm/book3s.c                |  4 +-
>  arch/powerpc/kvm/book3s.h                |  2 +-
>  arch/powerpc/kvm/book3s_64_mmu_hv.c      | 12 ++--
>  arch/powerpc/kvm/book3s_64_mmu_radix.c   |  4 +-
>  arch/powerpc/kvm/book3s_emulate.c        | 10 ++--
>  arch/powerpc/kvm/book3s_hv.c             | 60 ++++++++++----------
>  arch/powerpc/kvm/book3s_hv_nested.c      | 11 ++--
>  arch/powerpc/kvm/book3s_paired_singles.c | 72 ++++++++++++------------
>  arch/powerpc/kvm/book3s_pr.c             | 30 +++++-----
>  arch/powerpc/kvm/booke.c                 | 36 ++++++------
>  arch/powerpc/kvm/booke.h                 |  8 +--
>  arch/powerpc/kvm/booke_emulate.c         |  2 +-
>  arch/powerpc/kvm/e500_emulate.c          | 15 +++--
>  arch/powerpc/kvm/emulate.c               | 10 ++--
>  arch/powerpc/kvm/emulate_loadstore.c     | 32 +++++------
>  arch/powerpc/kvm/powerpc.c               | 72 ++++++++++++------------
>  arch/powerpc/kvm/trace_hv.h              |  6 +-
>  19 files changed, 212 insertions(+), 217 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/kvm_book3s.h b/arch/powerpc/include/asm/kvm_book3s.h
> index 506e4df2d730..66dbb1f85d59 100644
> --- a/arch/powerpc/include/asm/kvm_book3s.h
> +++ b/arch/powerpc/include/asm/kvm_book3s.h
> @@ -155,12 +155,11 @@ extern void kvmppc_mmu_unmap_page(struct kvm_vcpu *vcpu, struct kvmppc_pte *pte)
>  extern int kvmppc_mmu_map_segment(struct kvm_vcpu *vcpu, ulong eaddr);
>  extern void kvmppc_mmu_flush_segment(struct kvm_vcpu *vcpu, ulong eaddr, ulong seg_size);
>  extern void kvmppc_mmu_flush_segments(struct kvm_vcpu *vcpu);
> -extern int kvmppc_book3s_hv_page_fault(struct kvm_run *run,
> -			struct kvm_vcpu *vcpu, unsigned long addr,
> -			unsigned long status);
> +extern int kvmppc_book3s_hv_page_fault(struct kvm_vcpu *vcpu,
> +			unsigned long addr, unsigned long status);
>  extern long kvmppc_hv_find_lock_hpte(struct kvm *kvm, gva_t eaddr,
>  			unsigned long slb_v, unsigned long valid);
> -extern int kvmppc_hv_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +extern int kvmppc_hv_emulate_mmio(struct kvm_vcpu *vcpu,
>  			unsigned long gpa, gva_t ea, int is_store);
>  
>  extern void kvmppc_mmu_hpte_cache_map(struct kvm_vcpu *vcpu, struct hpte_cache *pte);
> @@ -174,8 +173,7 @@ extern void kvmppc_mmu_hpte_sysexit(void);
>  extern int kvmppc_mmu_hv_init(void);
>  extern int kvmppc_book3s_hcall_implemented(struct kvm *kvm, unsigned long hc);
>  
> -extern int kvmppc_book3s_radix_page_fault(struct kvm_run *run,
> -			struct kvm_vcpu *vcpu,
> +extern int kvmppc_book3s_radix_page_fault(struct kvm_vcpu *vcpu,
>  			unsigned long ea, unsigned long dsisr);
>  extern unsigned long __kvmhv_copy_tofrom_guest_radix(int lpid, int pid,
>  					gva_t eaddr, void *to, void *from,
> @@ -234,7 +232,7 @@ extern void kvmppc_trigger_fac_interrupt(struct kvm_vcpu *vcpu, ulong fac);
>  extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat,
>  			   bool upper, u32 val);
>  extern void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr);
> -extern int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu);
> +extern int kvmppc_emulate_paired_single(struct kvm_vcpu *vcpu);
>  extern kvm_pfn_t kvmppc_gpa_to_pfn(struct kvm_vcpu *vcpu, gpa_t gpa,
>  			bool writing, bool *writable);
>  extern void kvmppc_add_revmap_chain(struct kvm *kvm, struct revmap_entry *rev,
> @@ -300,12 +298,12 @@ void kvmhv_set_ptbl_entry(unsigned int lpid, u64 dw0, u64 dw1);
>  void kvmhv_release_all_nested(struct kvm *kvm);
>  long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu);
>  long kvmhv_do_nested_tlbie(struct kvm_vcpu *vcpu);
> -int kvmhv_run_single_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu,
> +int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu,
>  			  u64 time_limit, unsigned long lpcr);
>  void kvmhv_save_hv_regs(struct kvm_vcpu *vcpu, struct hv_guest_state *hr);
>  void kvmhv_restore_hv_return_state(struct kvm_vcpu *vcpu,
>  				   struct hv_guest_state *hr);
> -long int kvmhv_nested_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu);
> +long int kvmhv_nested_page_fault(struct kvm_vcpu *vcpu);
>  
>  void kvmppc_giveup_fac(struct kvm_vcpu *vcpu, ulong fac);
>  
> diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h
> index 94f5a32acaf1..ccf66b3a4c1d 100644
> --- a/arch/powerpc/include/asm/kvm_ppc.h
> +++ b/arch/powerpc/include/asm/kvm_ppc.h
> @@ -58,28 +58,28 @@ enum xlate_readwrite {
>  	XLATE_WRITE		/* check for write permissions */
>  };
>  
> -extern int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu);
> -extern int __kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu);
> +extern int kvmppc_vcpu_run(struct kvm_vcpu *vcpu);
> +extern int __kvmppc_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu);
>  extern void kvmppc_handler_highmem(void);
>  
>  extern void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu);
> -extern int kvmppc_handle_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +extern int kvmppc_handle_load(struct kvm_vcpu *vcpu,
>                                unsigned int rt, unsigned int bytes,
>  			      int is_default_endian);
> -extern int kvmppc_handle_loads(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +extern int kvmppc_handle_loads(struct kvm_vcpu *vcpu,
>                                 unsigned int rt, unsigned int bytes,
>  			       int is_default_endian);
> -extern int kvmppc_handle_vsx_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +extern int kvmppc_handle_vsx_load(struct kvm_vcpu *vcpu,
>  				unsigned int rt, unsigned int bytes,
>  			int is_default_endian, int mmio_sign_extend);
> -extern int kvmppc_handle_vmx_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +extern int kvmppc_handle_vmx_load(struct kvm_vcpu *vcpu,
>  		unsigned int rt, unsigned int bytes, int is_default_endian);
> -extern int kvmppc_handle_vmx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +extern int kvmppc_handle_vmx_store(struct kvm_vcpu *vcpu,
>  		unsigned int rs, unsigned int bytes, int is_default_endian);
> -extern int kvmppc_handle_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +extern int kvmppc_handle_store(struct kvm_vcpu *vcpu,
>  			       u64 val, unsigned int bytes,
>  			       int is_default_endian);
> -extern int kvmppc_handle_vsx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +extern int kvmppc_handle_vsx_store(struct kvm_vcpu *vcpu,
>  				int rs, unsigned int bytes,
>  				int is_default_endian);
>  
> @@ -90,10 +90,9 @@ extern int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr,
>  		     bool data);
>  extern int kvmppc_st(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr,
>  		     bool data);
> -extern int kvmppc_emulate_instruction(struct kvm_run *run,
> -                                      struct kvm_vcpu *vcpu);
> +extern int kvmppc_emulate_instruction(struct kvm_vcpu *vcpu);
>  extern int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu);
> -extern int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu);
> +extern int kvmppc_emulate_mmio(struct kvm_vcpu *vcpu);
>  extern void kvmppc_emulate_dec(struct kvm_vcpu *vcpu);
>  extern u32 kvmppc_get_dec(struct kvm_vcpu *vcpu, u64 tb);
>  extern void kvmppc_decrementer_func(struct kvm_vcpu *vcpu);
> @@ -267,7 +266,7 @@ struct kvmppc_ops {
>  	void (*vcpu_put)(struct kvm_vcpu *vcpu);
>  	void (*inject_interrupt)(struct kvm_vcpu *vcpu, int vec, u64 srr1_flags);
>  	void (*set_msr)(struct kvm_vcpu *vcpu, u64 msr);
> -	int (*vcpu_run)(struct kvm_run *run, struct kvm_vcpu *vcpu);
> +	int (*vcpu_run)(struct kvm_vcpu *vcpu);
>  	int (*vcpu_create)(struct kvm_vcpu *vcpu);
>  	void (*vcpu_free)(struct kvm_vcpu *vcpu);
>  	int (*check_requests)(struct kvm_vcpu *vcpu);
> @@ -291,7 +290,7 @@ struct kvmppc_ops {
>  	int (*init_vm)(struct kvm *kvm);
>  	void (*destroy_vm)(struct kvm *kvm);
>  	int (*get_smmu_info)(struct kvm *kvm, struct kvm_ppc_smmu_info *info);
> -	int (*emulate_op)(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +	int (*emulate_op)(struct kvm_vcpu *vcpu,
>  			  unsigned int inst, int *advance);
>  	int (*emulate_mtspr)(struct kvm_vcpu *vcpu, int sprn, ulong spr_val);
>  	int (*emulate_mfspr)(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val);
> diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c
> index 5690a1f9b976..345d22de213b 100644
> --- a/arch/powerpc/kvm/book3s.c
> +++ b/arch/powerpc/kvm/book3s.c
> @@ -758,9 +758,9 @@ void kvmppc_set_msr(struct kvm_vcpu *vcpu, u64 msr)
>  }
>  EXPORT_SYMBOL_GPL(kvmppc_set_msr);
>  
> -int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
> +int kvmppc_vcpu_run(struct kvm_vcpu *vcpu)
>  {
> -	return vcpu->kvm->arch.kvm_ops->vcpu_run(kvm_run, vcpu);
> +	return vcpu->kvm->arch.kvm_ops->vcpu_run(vcpu);
>  }
>  
>  int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
> diff --git a/arch/powerpc/kvm/book3s.h b/arch/powerpc/kvm/book3s.h
> index eae259ee49af..9b6323ec8e60 100644
> --- a/arch/powerpc/kvm/book3s.h
> +++ b/arch/powerpc/kvm/book3s.h
> @@ -18,7 +18,7 @@ extern void kvm_set_spte_hva_hv(struct kvm *kvm, unsigned long hva, pte_t pte);
>  
>  extern int kvmppc_mmu_init_pr(struct kvm_vcpu *vcpu);
>  extern void kvmppc_mmu_destroy_pr(struct kvm_vcpu *vcpu);
> -extern int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +extern int kvmppc_core_emulate_op_pr(struct kvm_vcpu *vcpu,
>  				     unsigned int inst, int *advance);
>  extern int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu,
>  					int sprn, ulong spr_val);
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
> index 2b35f9bcf892..36a07656ebbb 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
> @@ -413,7 +413,7 @@ static int instruction_is_store(unsigned int instr)
>  	return (instr & mask) != 0;
>  }
>  
> -int kvmppc_hv_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +int kvmppc_hv_emulate_mmio(struct kvm_vcpu *vcpu,
>  			   unsigned long gpa, gva_t ea, int is_store)
>  {
>  	u32 last_inst;
> @@ -473,10 +473,10 @@ int kvmppc_hv_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  
>  	vcpu->arch.paddr_accessed = gpa;
>  	vcpu->arch.vaddr_accessed = ea;
> -	return kvmppc_emulate_mmio(run, vcpu);
> +	return kvmppc_emulate_mmio(vcpu);
>  }
>  
> -int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +int kvmppc_book3s_hv_page_fault(struct kvm_vcpu *vcpu,
>  				unsigned long ea, unsigned long dsisr)
>  {
>  	struct kvm *kvm = vcpu->kvm;
> @@ -499,7 +499,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	pte_t pte, *ptep;
>  
>  	if (kvm_is_radix(kvm))
> -		return kvmppc_book3s_radix_page_fault(run, vcpu, ea, dsisr);
> +		return kvmppc_book3s_radix_page_fault(vcpu, ea, dsisr);
>  
>  	/*
>  	 * Real-mode code has already searched the HPT and found the
> @@ -519,7 +519,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			gpa_base = r & HPTE_R_RPN & ~(psize - 1);
>  			gfn_base = gpa_base >> PAGE_SHIFT;
>  			gpa = gpa_base | (ea & (psize - 1));
> -			return kvmppc_hv_emulate_mmio(run, vcpu, gpa, ea,
> +			return kvmppc_hv_emulate_mmio(vcpu, gpa, ea,
>  						dsisr & DSISR_ISSTORE);
>  		}
>  	}
> @@ -555,7 +555,7 @@ int kvmppc_book3s_hv_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  
>  	/* No memslot means it's an emulated MMIO region */
>  	if (!memslot || (memslot->flags & KVM_MEMSLOT_INVALID))
> -		return kvmppc_hv_emulate_mmio(run, vcpu, gpa, ea,
> +		return kvmppc_hv_emulate_mmio(vcpu, gpa, ea,
>  					      dsisr & DSISR_ISSTORE);
>  
>  	/*
> diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> index aa12cd4078b3..16c947bd5e87 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
> @@ -887,7 +887,7 @@ int kvmppc_book3s_instantiate_page(struct kvm_vcpu *vcpu,
>  	return ret;
>  }
>  
> -int kvmppc_book3s_radix_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +int kvmppc_book3s_radix_page_fault(struct kvm_vcpu *vcpu,
>  				   unsigned long ea, unsigned long dsisr)
>  {
>  	struct kvm *kvm = vcpu->kvm;
> @@ -933,7 +933,7 @@ int kvmppc_book3s_radix_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			kvmppc_core_queue_data_storage(vcpu, ea, dsisr);
>  			return RESUME_GUEST;
>  		}
> -		return kvmppc_hv_emulate_mmio(run, vcpu, gpa, ea, writing);
> +		return kvmppc_hv_emulate_mmio(vcpu, gpa, ea, writing);
>  	}
>  
>  	if (memslot->flags & KVM_MEM_READONLY) {
> diff --git a/arch/powerpc/kvm/book3s_emulate.c b/arch/powerpc/kvm/book3s_emulate.c
> index dad71d276b91..0effd48c8f4d 100644
> --- a/arch/powerpc/kvm/book3s_emulate.c
> +++ b/arch/powerpc/kvm/book3s_emulate.c
> @@ -235,7 +235,7 @@ void kvmppc_emulate_tabort(struct kvm_vcpu *vcpu, int ra_val)
>  
>  #endif
>  
> -int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +int kvmppc_core_emulate_op_pr(struct kvm_vcpu *vcpu,
>  			      unsigned int inst, int *advance)
>  {
>  	int emulated = EMULATE_DONE;
> @@ -371,13 +371,13 @@ int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			if (kvmppc_h_pr(vcpu, cmd) == EMULATE_DONE)
>  				break;
>  
> -			run->papr_hcall.nr = cmd;
> +			vcpu->run->papr_hcall.nr = cmd;
>  			for (i = 0; i < 9; ++i) {
>  				ulong gpr = kvmppc_get_gpr(vcpu, 4 + i);
> -				run->papr_hcall.args[i] = gpr;
> +				vcpu->run->papr_hcall.args[i] = gpr;
>  			}
>  
> -			run->exit_reason = KVM_EXIT_PAPR_HCALL;
> +			vcpu->run->exit_reason = KVM_EXIT_PAPR_HCALL;
>  			vcpu->arch.hcall_needed = 1;
>  			emulated = EMULATE_EXIT_USER;
>  			break;
> @@ -629,7 +629,7 @@ int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	}
>  
>  	if (emulated == EMULATE_FAIL)
> -		emulated = kvmppc_emulate_paired_single(run, vcpu);
> +		emulated = kvmppc_emulate_paired_single(vcpu);
>  
>  	return emulated;
>  }
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 413ea2dcb10c..296bc6fb4eb1 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -1156,8 +1156,7 @@ static int kvmppc_hcall_impl_hv(unsigned long cmd)
>  	return kvmppc_hcall_impl_hv_realmode(cmd);
>  }
>  
> -static int kvmppc_emulate_debug_inst(struct kvm_run *run,
> -					struct kvm_vcpu *vcpu)
> +static int kvmppc_emulate_debug_inst(struct kvm_vcpu *vcpu)
>  {
>  	u32 last_inst;
>  
> @@ -1171,8 +1170,8 @@ static int kvmppc_emulate_debug_inst(struct kvm_run *run,
>  	}
>  
>  	if (last_inst == KVMPPC_INST_SW_BREAKPOINT) {
> -		run->exit_reason = KVM_EXIT_DEBUG;
> -		run->debug.arch.address = kvmppc_get_pc(vcpu);
> +		vcpu->run->exit_reason = KVM_EXIT_DEBUG;
> +		vcpu->run->debug.arch.address = kvmppc_get_pc(vcpu);
>  		return RESUME_HOST;
>  	} else {
>  		kvmppc_core_queue_program(vcpu, SRR1_PROGILL);
> @@ -1273,9 +1272,10 @@ static int kvmppc_emulate_doorbell_instr(struct kvm_vcpu *vcpu)
>  	return RESUME_GUEST;
>  }
>  
> -static int kvmppc_handle_exit_hv(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +static int kvmppc_handle_exit_hv(struct kvm_vcpu *vcpu,
>  				 struct task_struct *tsk)
>  {
> +	struct kvm_run *run = vcpu->run;
>  	int r = RESUME_HOST;
>  
>  	vcpu->stat.sum_exits++;
> @@ -1410,7 +1410,7 @@ static int kvmppc_handle_exit_hv(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  				swab32(vcpu->arch.emul_inst) :
>  				vcpu->arch.emul_inst;
>  		if (vcpu->guest_debug & KVM_GUESTDBG_USE_SW_BP) {
> -			r = kvmppc_emulate_debug_inst(run, vcpu);
> +			r = kvmppc_emulate_debug_inst(vcpu);
>  		} else {
>  			kvmppc_core_queue_program(vcpu, SRR1_PROGILL);
>  			r = RESUME_GUEST;
> @@ -1462,7 +1462,7 @@ static int kvmppc_handle_exit_hv(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	return r;
>  }
>  
> -static int kvmppc_handle_nested_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
> +static int kvmppc_handle_nested_exit(struct kvm_vcpu *vcpu)
>  {
>  	int r;
>  	int srcu_idx;
> @@ -1520,7 +1520,7 @@ static int kvmppc_handle_nested_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  	 */
>  	case BOOK3S_INTERRUPT_H_DATA_STORAGE:
>  		srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
> -		r = kvmhv_nested_page_fault(run, vcpu);
> +		r = kvmhv_nested_page_fault(vcpu);
>  		srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx);
>  		break;
>  	case BOOK3S_INTERRUPT_H_INST_STORAGE:
> @@ -1530,7 +1530,7 @@ static int kvmppc_handle_nested_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  		if (vcpu->arch.shregs.msr & HSRR1_HISI_WRITE)
>  			vcpu->arch.fault_dsisr |= DSISR_ISSTORE;
>  		srcu_idx = srcu_read_lock(&vcpu->kvm->srcu);
> -		r = kvmhv_nested_page_fault(run, vcpu);
> +		r = kvmhv_nested_page_fault(vcpu);
>  		srcu_read_unlock(&vcpu->kvm->srcu, srcu_idx);
>  		break;
>  
> @@ -2934,7 +2934,7 @@ static void post_guest_process(struct kvmppc_vcore *vc, bool is_master)
>  
>  		ret = RESUME_GUEST;
>  		if (vcpu->arch.trap)
> -			ret = kvmppc_handle_exit_hv(vcpu->run, vcpu,
> +			ret = kvmppc_handle_exit_hv(vcpu,
>  						    vcpu->arch.run_task);
>  
>  		vcpu->arch.ret = ret;
> @@ -3900,15 +3900,16 @@ static int kvmhv_setup_mmu(struct kvm_vcpu *vcpu)
>  	return r;
>  }
>  
> -static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
> +static int kvmppc_run_vcpu(struct kvm_vcpu *vcpu)
>  {
> +	struct kvm_run *run = vcpu->run;
>  	int n_ceded, i, r;
>  	struct kvmppc_vcore *vc;
>  	struct kvm_vcpu *v;
>  
>  	trace_kvmppc_run_vcpu_enter(vcpu);
>  
> -	kvm_run->exit_reason = 0;
> +	run->exit_reason = 0;
>  	vcpu->arch.ret = RESUME_GUEST;
>  	vcpu->arch.trap = 0;
>  	kvmppc_update_vpas(vcpu);
> @@ -3952,8 +3953,8 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  			r = kvmhv_setup_mmu(vcpu);
>  			spin_lock(&vc->lock);
>  			if (r) {
> -				kvm_run->exit_reason = KVM_EXIT_FAIL_ENTRY;
> -				kvm_run->fail_entry.
> +				run->exit_reason = KVM_EXIT_FAIL_ENTRY;
> +				run->fail_entry.
>  					hardware_entry_failure_reason = 0;
>  				vcpu->arch.ret = r;
>  				break;
> @@ -4013,7 +4014,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  	if (vcpu->arch.state == KVMPPC_VCPU_RUNNABLE) {
>  		kvmppc_remove_runnable(vc, vcpu);
>  		vcpu->stat.signal_exits++;
> -		kvm_run->exit_reason = KVM_EXIT_INTR;
> +		run->exit_reason = KVM_EXIT_INTR;
>  		vcpu->arch.ret = -EINTR;
>  	}
>  
> @@ -4024,15 +4025,15 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  		wake_up(&v->arch.cpu_run);
>  	}
>  
> -	trace_kvmppc_run_vcpu_exit(vcpu, kvm_run);
> +	trace_kvmppc_run_vcpu_exit(vcpu);
>  	spin_unlock(&vc->lock);
>  	return vcpu->arch.ret;
>  }
>  
> -int kvmhv_run_single_vcpu(struct kvm_run *kvm_run,
> -			  struct kvm_vcpu *vcpu, u64 time_limit,
> +int kvmhv_run_single_vcpu(struct kvm_vcpu *vcpu, u64 time_limit,
>  			  unsigned long lpcr)
>  {
> +	struct kvm_run *run = vcpu->run;
>  	int trap, r, pcpu;
>  	int srcu_idx, lpid;
>  	struct kvmppc_vcore *vc;
> @@ -4041,7 +4042,7 @@ int kvmhv_run_single_vcpu(struct kvm_run *kvm_run,
>  
>  	trace_kvmppc_run_vcpu_enter(vcpu);
>  
> -	kvm_run->exit_reason = 0;
> +	run->exit_reason = 0;
>  	vcpu->arch.ret = RESUME_GUEST;
>  	vcpu->arch.trap = 0;
>  
> @@ -4165,9 +4166,9 @@ int kvmhv_run_single_vcpu(struct kvm_run *kvm_run,
>  	r = RESUME_GUEST;
>  	if (trap) {
>  		if (!nested)
> -			r = kvmppc_handle_exit_hv(kvm_run, vcpu, current);
> +			r = kvmppc_handle_exit_hv(vcpu, current);
>  		else
> -			r = kvmppc_handle_nested_exit(kvm_run, vcpu);
> +			r = kvmppc_handle_nested_exit(vcpu);
>  	}
>  	vcpu->arch.ret = r;
>  
> @@ -4177,7 +4178,7 @@ int kvmhv_run_single_vcpu(struct kvm_run *kvm_run,
>  		while (vcpu->arch.ceded && !kvmppc_vcpu_woken(vcpu)) {
>  			if (signal_pending(current)) {
>  				vcpu->stat.signal_exits++;
> -				kvm_run->exit_reason = KVM_EXIT_INTR;
> +				run->exit_reason = KVM_EXIT_INTR;
>  				vcpu->arch.ret = -EINTR;
>  				break;
>  			}
> @@ -4193,13 +4194,13 @@ int kvmhv_run_single_vcpu(struct kvm_run *kvm_run,
>  
>   done:
>  	kvmppc_remove_runnable(vc, vcpu);
> -	trace_kvmppc_run_vcpu_exit(vcpu, kvm_run);
> +	trace_kvmppc_run_vcpu_exit(vcpu);
>  
>  	return vcpu->arch.ret;
>  
>   sigpend:
>  	vcpu->stat.signal_exits++;
> -	kvm_run->exit_reason = KVM_EXIT_INTR;
> +	run->exit_reason = KVM_EXIT_INTR;
>  	vcpu->arch.ret = -EINTR;
>   out:
>  	local_irq_enable();
> @@ -4207,8 +4208,9 @@ int kvmhv_run_single_vcpu(struct kvm_run *kvm_run,
>  	goto done;
>  }
>  
> -static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
> +static int kvmppc_vcpu_run_hv(struct kvm_vcpu *vcpu)
>  {
> +	struct kvm_run *run = vcpu->run;
>  	int r;
>  	int srcu_idx;
>  	unsigned long ebb_regs[3] = {};	/* shut up GCC */
> @@ -4292,10 +4294,10 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  		 */
>  		if (kvm->arch.threads_indep && kvm_is_radix(kvm) &&
>  		    !no_mixing_hpt_and_radix)
> -			r = kvmhv_run_single_vcpu(run, vcpu, ~(u64)0,
> +			r = kvmhv_run_single_vcpu(vcpu, ~(u64)0,
>  						  vcpu->arch.vcore->lpcr);
>  		else
> -			r = kvmppc_run_vcpu(run, vcpu);
> +			r = kvmppc_run_vcpu(vcpu);
>  
>  		if (run->exit_reason == KVM_EXIT_PAPR_HCALL &&
>  		    !(vcpu->arch.shregs.msr & MSR_PR)) {
> @@ -4305,7 +4307,7 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			kvmppc_core_prepare_to_enter(vcpu);
>  		} else if (r == RESUME_PAGE_FAULT) {
>  			srcu_idx = srcu_read_lock(&kvm->srcu);
> -			r = kvmppc_book3s_hv_page_fault(run, vcpu,
> +			r = kvmppc_book3s_hv_page_fault(vcpu,
>  				vcpu->arch.fault_dar, vcpu->arch.fault_dsisr);
>  			srcu_read_unlock(&kvm->srcu, srcu_idx);
>  		} else if (r == RESUME_PASSTHROUGH) {
> @@ -4979,7 +4981,7 @@ static void kvmppc_core_destroy_vm_hv(struct kvm *kvm)
>  }
>  
>  /* We don't need to emulate any privileged instructions or dcbz */
> -static int kvmppc_core_emulate_op_hv(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +static int kvmppc_core_emulate_op_hv(struct kvm_vcpu *vcpu,
>  				     unsigned int inst, int *advance)
>  {
>  	return EMULATE_FAIL;
> diff --git a/arch/powerpc/kvm/book3s_hv_nested.c b/arch/powerpc/kvm/book3s_hv_nested.c
> index 5a3987f3ebf3..fe4c535882e6 100644
> --- a/arch/powerpc/kvm/book3s_hv_nested.c
> +++ b/arch/powerpc/kvm/book3s_hv_nested.c
> @@ -290,7 +290,7 @@ long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu)
>  			r = RESUME_HOST;
>  			break;
>  		}
> -		r = kvmhv_run_single_vcpu(vcpu->run, vcpu, hdec_exp, lpcr);
> +		r = kvmhv_run_single_vcpu(vcpu, hdec_exp, lpcr);
>  	} while (is_kvmppc_resume_guest(r));
>  
>  	/* save L2 state for return */
> @@ -1256,8 +1256,7 @@ static inline int kvmppc_radix_shift_to_level(int shift)
>  }
>  
>  /* called with gp->tlb_lock held */
> -static long int __kvmhv_nested_page_fault(struct kvm_run *run,
> -					  struct kvm_vcpu *vcpu,
> +static long int __kvmhv_nested_page_fault(struct kvm_vcpu *vcpu,
>  					  struct kvm_nested_guest *gp)
>  {
>  	struct kvm *kvm = vcpu->kvm;
> @@ -1340,7 +1339,7 @@ static long int __kvmhv_nested_page_fault(struct kvm_run *run,
>  		}
>  
>  		/* passthrough of emulated MMIO case */
> -		return kvmppc_hv_emulate_mmio(run, vcpu, gpa, ea, writing);
> +		return kvmppc_hv_emulate_mmio(vcpu, gpa, ea, writing);
>  	}
>  	if (memslot->flags & KVM_MEM_READONLY) {
>  		if (writing) {
> @@ -1427,13 +1426,13 @@ static long int __kvmhv_nested_page_fault(struct kvm_run *run,
>  	return RESUME_GUEST;
>  }
>  
> -long int kvmhv_nested_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu)
> +long int kvmhv_nested_page_fault(struct kvm_vcpu *vcpu)
>  {
>  	struct kvm_nested_guest *gp = vcpu->arch.nested;
>  	long int ret;
>  
>  	mutex_lock(&gp->tlb_lock);
> -	ret = __kvmhv_nested_page_fault(run, vcpu, gp);
> +	ret = __kvmhv_nested_page_fault(vcpu, gp);
>  	mutex_unlock(&gp->tlb_lock);
>  	return ret;
>  }
> diff --git a/arch/powerpc/kvm/book3s_paired_singles.c b/arch/powerpc/kvm/book3s_paired_singles.c
> index bf0282775e37..a11436720a8c 100644
> --- a/arch/powerpc/kvm/book3s_paired_singles.c
> +++ b/arch/powerpc/kvm/book3s_paired_singles.c
> @@ -169,7 +169,7 @@ static void kvmppc_inject_pf(struct kvm_vcpu *vcpu, ulong eaddr, bool is_store)
>  	kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_DATA_STORAGE);
>  }
>  
> -static int kvmppc_emulate_fpr_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +static int kvmppc_emulate_fpr_load(struct kvm_vcpu *vcpu,
>  				   int rs, ulong addr, int ls_type)
>  {
>  	int emulated = EMULATE_FAIL;
> @@ -188,7 +188,7 @@ static int kvmppc_emulate_fpr_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  		kvmppc_inject_pf(vcpu, addr, false);
>  		goto done_load;
>  	} else if (r == EMULATE_DO_MMIO) {
> -		emulated = kvmppc_handle_load(run, vcpu, KVM_MMIO_REG_FPR | rs,
> +		emulated = kvmppc_handle_load(vcpu, KVM_MMIO_REG_FPR | rs,
>  					      len, 1);
>  		goto done_load;
>  	}
> @@ -213,7 +213,7 @@ static int kvmppc_emulate_fpr_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	return emulated;
>  }
>  
> -static int kvmppc_emulate_fpr_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +static int kvmppc_emulate_fpr_store(struct kvm_vcpu *vcpu,
>  				    int rs, ulong addr, int ls_type)
>  {
>  	int emulated = EMULATE_FAIL;
> @@ -248,7 +248,7 @@ static int kvmppc_emulate_fpr_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	if (r < 0) {
>  		kvmppc_inject_pf(vcpu, addr, true);
>  	} else if (r == EMULATE_DO_MMIO) {
> -		emulated = kvmppc_handle_store(run, vcpu, val, len, 1);
> +		emulated = kvmppc_handle_store(vcpu, val, len, 1);
>  	} else {
>  		emulated = EMULATE_DONE;
>  	}
> @@ -259,7 +259,7 @@ static int kvmppc_emulate_fpr_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	return emulated;
>  }
>  
> -static int kvmppc_emulate_psq_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +static int kvmppc_emulate_psq_load(struct kvm_vcpu *vcpu,
>  				   int rs, ulong addr, bool w, int i)
>  {
>  	int emulated = EMULATE_FAIL;
> @@ -279,12 +279,12 @@ static int kvmppc_emulate_psq_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  		kvmppc_inject_pf(vcpu, addr, false);
>  		goto done_load;
>  	} else if ((r == EMULATE_DO_MMIO) && w) {
> -		emulated = kvmppc_handle_load(run, vcpu, KVM_MMIO_REG_FPR | rs,
> +		emulated = kvmppc_handle_load(vcpu, KVM_MMIO_REG_FPR | rs,
>  					      4, 1);
>  		vcpu->arch.qpr[rs] = tmp[1];
>  		goto done_load;
>  	} else if (r == EMULATE_DO_MMIO) {
> -		emulated = kvmppc_handle_load(run, vcpu, KVM_MMIO_REG_FQPR | rs,
> +		emulated = kvmppc_handle_load(vcpu, KVM_MMIO_REG_FQPR | rs,
>  					      8, 1);
>  		goto done_load;
>  	}
> @@ -302,7 +302,7 @@ static int kvmppc_emulate_psq_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	return emulated;
>  }
>  
> -static int kvmppc_emulate_psq_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +static int kvmppc_emulate_psq_store(struct kvm_vcpu *vcpu,
>  				    int rs, ulong addr, bool w, int i)
>  {
>  	int emulated = EMULATE_FAIL;
> @@ -318,10 +318,10 @@ static int kvmppc_emulate_psq_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	if (r < 0) {
>  		kvmppc_inject_pf(vcpu, addr, true);
>  	} else if ((r == EMULATE_DO_MMIO) && w) {
> -		emulated = kvmppc_handle_store(run, vcpu, tmp[0], 4, 1);
> +		emulated = kvmppc_handle_store(vcpu, tmp[0], 4, 1);
>  	} else if (r == EMULATE_DO_MMIO) {
>  		u64 val = ((u64)tmp[0] << 32) | tmp[1];
> -		emulated = kvmppc_handle_store(run, vcpu, val, 8, 1);
> +		emulated = kvmppc_handle_store(vcpu, val, 8, 1);
>  	} else {
>  		emulated = EMULATE_DONE;
>  	}
> @@ -618,7 +618,7 @@ static int kvmppc_ps_one_in(struct kvm_vcpu *vcpu, bool rc,
>  	return EMULATE_DONE;
>  }
>  
> -int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
> +int kvmppc_emulate_paired_single(struct kvm_vcpu *vcpu)
>  {
>  	u32 inst;
>  	enum emulation_result emulated = EMULATE_DONE;
> @@ -680,7 +680,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  		int i = inst_get_field(inst, 17, 19);
>  
>  		addr += get_d_signext(inst);
> -		emulated = kvmppc_emulate_psq_load(run, vcpu, ax_rd, addr, w, i);
> +		emulated = kvmppc_emulate_psq_load(vcpu, ax_rd, addr, w, i);
>  		break;
>  	}
>  	case OP_PSQ_LU:
> @@ -690,7 +690,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  		int i = inst_get_field(inst, 17, 19);
>  
>  		addr += get_d_signext(inst);
> -		emulated = kvmppc_emulate_psq_load(run, vcpu, ax_rd, addr, w, i);
> +		emulated = kvmppc_emulate_psq_load(vcpu, ax_rd, addr, w, i);
>  
>  		if (emulated == EMULATE_DONE)
>  			kvmppc_set_gpr(vcpu, ax_ra, addr);
> @@ -703,7 +703,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  		int i = inst_get_field(inst, 17, 19);
>  
>  		addr += get_d_signext(inst);
> -		emulated = kvmppc_emulate_psq_store(run, vcpu, ax_rd, addr, w, i);
> +		emulated = kvmppc_emulate_psq_store(vcpu, ax_rd, addr, w, i);
>  		break;
>  	}
>  	case OP_PSQ_STU:
> @@ -713,7 +713,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  		int i = inst_get_field(inst, 17, 19);
>  
>  		addr += get_d_signext(inst);
> -		emulated = kvmppc_emulate_psq_store(run, vcpu, ax_rd, addr, w, i);
> +		emulated = kvmppc_emulate_psq_store(vcpu, ax_rd, addr, w, i);
>  
>  		if (emulated == EMULATE_DONE)
>  			kvmppc_set_gpr(vcpu, ax_ra, addr);
> @@ -733,7 +733,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			int i = inst_get_field(inst, 22, 24);
>  
>  			addr += kvmppc_get_gpr(vcpu, ax_rb);
> -			emulated = kvmppc_emulate_psq_load(run, vcpu, ax_rd, addr, w, i);
> +			emulated = kvmppc_emulate_psq_load(vcpu, ax_rd, addr, w, i);
>  			break;
>  		}
>  		case OP_4X_PS_CMPO0:
> @@ -747,7 +747,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			int i = inst_get_field(inst, 22, 24);
>  
>  			addr += kvmppc_get_gpr(vcpu, ax_rb);
> -			emulated = kvmppc_emulate_psq_load(run, vcpu, ax_rd, addr, w, i);
> +			emulated = kvmppc_emulate_psq_load(vcpu, ax_rd, addr, w, i);
>  
>  			if (emulated == EMULATE_DONE)
>  				kvmppc_set_gpr(vcpu, ax_ra, addr);
> @@ -824,7 +824,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			int i = inst_get_field(inst, 22, 24);
>  
>  			addr += kvmppc_get_gpr(vcpu, ax_rb);
> -			emulated = kvmppc_emulate_psq_store(run, vcpu, ax_rd, addr, w, i);
> +			emulated = kvmppc_emulate_psq_store(vcpu, ax_rd, addr, w, i);
>  			break;
>  		}
>  		case OP_4XW_PSQ_STUX:
> @@ -834,7 +834,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			int i = inst_get_field(inst, 22, 24);
>  
>  			addr += kvmppc_get_gpr(vcpu, ax_rb);
> -			emulated = kvmppc_emulate_psq_store(run, vcpu, ax_rd, addr, w, i);
> +			emulated = kvmppc_emulate_psq_store(vcpu, ax_rd, addr, w, i);
>  
>  			if (emulated == EMULATE_DONE)
>  				kvmppc_set_gpr(vcpu, ax_ra, addr);
> @@ -922,7 +922,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  	{
>  		ulong addr = (ax_ra ? kvmppc_get_gpr(vcpu, ax_ra) : 0) + full_d;
>  
> -		emulated = kvmppc_emulate_fpr_load(run, vcpu, ax_rd, addr,
> +		emulated = kvmppc_emulate_fpr_load(vcpu, ax_rd, addr,
>  						   FPU_LS_SINGLE);
>  		break;
>  	}
> @@ -930,7 +930,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  	{
>  		ulong addr = kvmppc_get_gpr(vcpu, ax_ra) + full_d;
>  
> -		emulated = kvmppc_emulate_fpr_load(run, vcpu, ax_rd, addr,
> +		emulated = kvmppc_emulate_fpr_load(vcpu, ax_rd, addr,
>  						   FPU_LS_SINGLE);
>  
>  		if (emulated == EMULATE_DONE)
> @@ -941,7 +941,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  	{
>  		ulong addr = (ax_ra ? kvmppc_get_gpr(vcpu, ax_ra) : 0) + full_d;
>  
> -		emulated = kvmppc_emulate_fpr_load(run, vcpu, ax_rd, addr,
> +		emulated = kvmppc_emulate_fpr_load(vcpu, ax_rd, addr,
>  						   FPU_LS_DOUBLE);
>  		break;
>  	}
> @@ -949,7 +949,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  	{
>  		ulong addr = kvmppc_get_gpr(vcpu, ax_ra) + full_d;
>  
> -		emulated = kvmppc_emulate_fpr_load(run, vcpu, ax_rd, addr,
> +		emulated = kvmppc_emulate_fpr_load(vcpu, ax_rd, addr,
>  						   FPU_LS_DOUBLE);
>  
>  		if (emulated == EMULATE_DONE)
> @@ -960,7 +960,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  	{
>  		ulong addr = (ax_ra ? kvmppc_get_gpr(vcpu, ax_ra) : 0) + full_d;
>  
> -		emulated = kvmppc_emulate_fpr_store(run, vcpu, ax_rd, addr,
> +		emulated = kvmppc_emulate_fpr_store(vcpu, ax_rd, addr,
>  						    FPU_LS_SINGLE);
>  		break;
>  	}
> @@ -968,7 +968,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  	{
>  		ulong addr = kvmppc_get_gpr(vcpu, ax_ra) + full_d;
>  
> -		emulated = kvmppc_emulate_fpr_store(run, vcpu, ax_rd, addr,
> +		emulated = kvmppc_emulate_fpr_store(vcpu, ax_rd, addr,
>  						    FPU_LS_SINGLE);
>  
>  		if (emulated == EMULATE_DONE)
> @@ -979,7 +979,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  	{
>  		ulong addr = (ax_ra ? kvmppc_get_gpr(vcpu, ax_ra) : 0) + full_d;
>  
> -		emulated = kvmppc_emulate_fpr_store(run, vcpu, ax_rd, addr,
> +		emulated = kvmppc_emulate_fpr_store(vcpu, ax_rd, addr,
>  						    FPU_LS_DOUBLE);
>  		break;
>  	}
> @@ -987,7 +987,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  	{
>  		ulong addr = kvmppc_get_gpr(vcpu, ax_ra) + full_d;
>  
> -		emulated = kvmppc_emulate_fpr_store(run, vcpu, ax_rd, addr,
> +		emulated = kvmppc_emulate_fpr_store(vcpu, ax_rd, addr,
>  						    FPU_LS_DOUBLE);
>  
>  		if (emulated == EMULATE_DONE)
> @@ -1001,7 +1001,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			ulong addr = ax_ra ? kvmppc_get_gpr(vcpu, ax_ra) : 0;
>  
>  			addr += kvmppc_get_gpr(vcpu, ax_rb);
> -			emulated = kvmppc_emulate_fpr_load(run, vcpu, ax_rd,
> +			emulated = kvmppc_emulate_fpr_load(vcpu, ax_rd,
>  							   addr, FPU_LS_SINGLE);
>  			break;
>  		}
> @@ -1010,7 +1010,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			ulong addr = kvmppc_get_gpr(vcpu, ax_ra) +
>  				     kvmppc_get_gpr(vcpu, ax_rb);
>  
> -			emulated = kvmppc_emulate_fpr_load(run, vcpu, ax_rd,
> +			emulated = kvmppc_emulate_fpr_load(vcpu, ax_rd,
>  							   addr, FPU_LS_SINGLE);
>  
>  			if (emulated == EMULATE_DONE)
> @@ -1022,7 +1022,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			ulong addr = (ax_ra ? kvmppc_get_gpr(vcpu, ax_ra) : 0) +
>  				     kvmppc_get_gpr(vcpu, ax_rb);
>  
> -			emulated = kvmppc_emulate_fpr_load(run, vcpu, ax_rd,
> +			emulated = kvmppc_emulate_fpr_load(vcpu, ax_rd,
>  							   addr, FPU_LS_DOUBLE);
>  			break;
>  		}
> @@ -1031,7 +1031,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			ulong addr = kvmppc_get_gpr(vcpu, ax_ra) +
>  				     kvmppc_get_gpr(vcpu, ax_rb);
>  
> -			emulated = kvmppc_emulate_fpr_load(run, vcpu, ax_rd,
> +			emulated = kvmppc_emulate_fpr_load(vcpu, ax_rd,
>  							   addr, FPU_LS_DOUBLE);
>  
>  			if (emulated == EMULATE_DONE)
> @@ -1043,7 +1043,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			ulong addr = (ax_ra ? kvmppc_get_gpr(vcpu, ax_ra) : 0) +
>  				     kvmppc_get_gpr(vcpu, ax_rb);
>  
> -			emulated = kvmppc_emulate_fpr_store(run, vcpu, ax_rd,
> +			emulated = kvmppc_emulate_fpr_store(vcpu, ax_rd,
>  							    addr, FPU_LS_SINGLE);
>  			break;
>  		}
> @@ -1052,7 +1052,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			ulong addr = kvmppc_get_gpr(vcpu, ax_ra) +
>  				     kvmppc_get_gpr(vcpu, ax_rb);
>  
> -			emulated = kvmppc_emulate_fpr_store(run, vcpu, ax_rd,
> +			emulated = kvmppc_emulate_fpr_store(vcpu, ax_rd,
>  							    addr, FPU_LS_SINGLE);
>  
>  			if (emulated == EMULATE_DONE)
> @@ -1064,7 +1064,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			ulong addr = (ax_ra ? kvmppc_get_gpr(vcpu, ax_ra) : 0) +
>  				     kvmppc_get_gpr(vcpu, ax_rb);
>  
> -			emulated = kvmppc_emulate_fpr_store(run, vcpu, ax_rd,
> +			emulated = kvmppc_emulate_fpr_store(vcpu, ax_rd,
>  							    addr, FPU_LS_DOUBLE);
>  			break;
>  		}
> @@ -1073,7 +1073,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			ulong addr = kvmppc_get_gpr(vcpu, ax_ra) +
>  				     kvmppc_get_gpr(vcpu, ax_rb);
>  
> -			emulated = kvmppc_emulate_fpr_store(run, vcpu, ax_rd,
> +			emulated = kvmppc_emulate_fpr_store(vcpu, ax_rd,
>  							    addr, FPU_LS_DOUBLE);
>  
>  			if (emulated == EMULATE_DONE)
> @@ -1085,7 +1085,7 @@ int kvmppc_emulate_paired_single(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  			ulong addr = (ax_ra ? kvmppc_get_gpr(vcpu, ax_ra) : 0) +
>  				     kvmppc_get_gpr(vcpu, ax_rb);
>  
> -			emulated = kvmppc_emulate_fpr_store(run, vcpu, ax_rd,
> +			emulated = kvmppc_emulate_fpr_store(vcpu, ax_rd,
>  							    addr,
>  							    FPU_LS_SINGLE_LOW);
>  			break;
> diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
> index a0f6813f4560..ef54f917bdaf 100644
> --- a/arch/powerpc/kvm/book3s_pr.c
> +++ b/arch/powerpc/kvm/book3s_pr.c
> @@ -700,7 +700,7 @@ static bool kvmppc_visible_gpa(struct kvm_vcpu *vcpu, gpa_t gpa)
>  	return kvm_is_visible_gfn(vcpu->kvm, gpa >> PAGE_SHIFT);
>  }
>  
> -int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +static int kvmppc_handle_pagefault(struct kvm_vcpu *vcpu,
>  			    ulong eaddr, int vec)
>  {
>  	bool data = (vec == BOOK3S_INTERRUPT_DATA_STORAGE);
> @@ -795,7 +795,7 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  		/* The guest's PTE is not mapped yet. Map on the host */
>  		if (kvmppc_mmu_map_page(vcpu, &pte, iswrite) == -EIO) {
>  			/* Exit KVM if mapping failed */
> -			run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
> +			vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
>  			return RESUME_HOST;
>  		}
>  		if (data)
> @@ -808,7 +808,7 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  		vcpu->stat.mmio_exits++;
>  		vcpu->arch.paddr_accessed = pte.raddr;
>  		vcpu->arch.vaddr_accessed = pte.eaddr;
> -		r = kvmppc_emulate_mmio(run, vcpu);
> +		r = kvmppc_emulate_mmio(vcpu);
>  		if ( r == RESUME_HOST_NV )
>  			r = RESUME_HOST;
>  	}
> @@ -992,7 +992,7 @@ static void kvmppc_emulate_fac(struct kvm_vcpu *vcpu, ulong fac)
>  	enum emulation_result er = EMULATE_FAIL;
>  
>  	if (!(kvmppc_get_msr(vcpu) & MSR_PR))
> -		er = kvmppc_emulate_instruction(vcpu->run, vcpu);
> +		er = kvmppc_emulate_instruction(vcpu);
>  
>  	if ((er != EMULATE_DONE) && (er != EMULATE_AGAIN)) {
>  		/* Couldn't emulate, trigger interrupt in guest */
> @@ -1089,8 +1089,7 @@ static void kvmppc_clear_debug(struct kvm_vcpu *vcpu)
>  	}
>  }
>  
> -static int kvmppc_exit_pr_progint(struct kvm_run *run, struct kvm_vcpu *vcpu,
> -				  unsigned int exit_nr)
> +static int kvmppc_exit_pr_progint(struct kvm_vcpu *vcpu, unsigned int exit_nr)
>  {
>  	enum emulation_result er;
>  	ulong flags;
> @@ -1124,7 +1123,7 @@ static int kvmppc_exit_pr_progint(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	}
>  
>  	vcpu->stat.emulated_inst_exits++;
> -	er = kvmppc_emulate_instruction(run, vcpu);
> +	er = kvmppc_emulate_instruction(vcpu);
>  	switch (er) {
>  	case EMULATE_DONE:
>  		r = RESUME_GUEST_NV;
> @@ -1139,7 +1138,7 @@ static int kvmppc_exit_pr_progint(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  		r = RESUME_GUEST;
>  		break;
>  	case EMULATE_DO_MMIO:
> -		run->exit_reason = KVM_EXIT_MMIO;
> +		vcpu->run->exit_reason = KVM_EXIT_MMIO;
>  		r = RESUME_HOST_NV;
>  		break;
>  	case EMULATE_EXIT_USER:
> @@ -1198,7 +1197,7 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  		/* only care about PTEG not found errors, but leave NX alone */
>  		if (shadow_srr1 & 0x40000000) {
>  			int idx = srcu_read_lock(&vcpu->kvm->srcu);
> -			r = kvmppc_handle_pagefault(run, vcpu, kvmppc_get_pc(vcpu), exit_nr);
> +			r = kvmppc_handle_pagefault(vcpu, kvmppc_get_pc(vcpu), exit_nr);
>  			srcu_read_unlock(&vcpu->kvm->srcu, idx);
>  			vcpu->stat.sp_instruc++;
>  		} else if (vcpu->arch.mmu.is_dcbz32(vcpu) &&
> @@ -1248,7 +1247,7 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  		 */
>  		if (fault_dsisr & (DSISR_NOHPTE | DSISR_PROTFAULT)) {
>  			int idx = srcu_read_lock(&vcpu->kvm->srcu);
> -			r = kvmppc_handle_pagefault(run, vcpu, dar, exit_nr);
> +			r = kvmppc_handle_pagefault(vcpu, dar, exit_nr);
>  			srcu_read_unlock(&vcpu->kvm->srcu, idx);
>  		} else {
>  			kvmppc_core_queue_data_storage(vcpu, dar, fault_dsisr);
> @@ -1292,7 +1291,7 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  		break;
>  	case BOOK3S_INTERRUPT_PROGRAM:
>  	case BOOK3S_INTERRUPT_H_EMUL_ASSIST:
> -		r = kvmppc_exit_pr_progint(run, vcpu, exit_nr);
> +		r = kvmppc_exit_pr_progint(vcpu, exit_nr);
>  		break;
>  	case BOOK3S_INTERRUPT_SYSCALL:
>  	{
> @@ -1370,7 +1369,7 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			emul = kvmppc_get_last_inst(vcpu, INST_GENERIC,
>  						    &last_inst);
>  			if (emul == EMULATE_DONE)
> -				r = kvmppc_exit_pr_progint(run, vcpu, exit_nr);
> +				r = kvmppc_exit_pr_progint(vcpu, exit_nr);
>  			else
>  				r = RESUME_GUEST;
>  
> @@ -1825,8 +1824,9 @@ static void kvmppc_core_vcpu_free_pr(struct kvm_vcpu *vcpu)
>  	vfree(vcpu_book3s);
>  }
>  
> -static int kvmppc_vcpu_run_pr(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
> +static int kvmppc_vcpu_run_pr(struct kvm_vcpu *vcpu)
>  {
> +	struct kvm_run *run = vcpu->run;
>  	int ret;
>  #ifdef CONFIG_ALTIVEC
>  	unsigned long uninitialized_var(vrsave);
> @@ -1834,7 +1834,7 @@ static int kvmppc_vcpu_run_pr(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  
>  	/* Check if we can run the vcpu at all */
>  	if (!vcpu->arch.sane) {
> -		kvm_run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
> +		run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
>  		ret = -EINVAL;
>  		goto out;
>  	}
> @@ -1861,7 +1861,7 @@ static int kvmppc_vcpu_run_pr(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  
>  	kvmppc_fix_ee_before_entry();
>  
> -	ret = __kvmppc_vcpu_run(kvm_run, vcpu);
> +	ret = __kvmppc_vcpu_run(run, vcpu);
>  
>  	kvmppc_clear_debug(vcpu);
>  
> diff --git a/arch/powerpc/kvm/booke.c b/arch/powerpc/kvm/booke.c
> index 6c18ea88fd25..26b3f5900b72 100644
> --- a/arch/powerpc/kvm/booke.c
> +++ b/arch/powerpc/kvm/booke.c
> @@ -730,13 +730,14 @@ int kvmppc_core_check_requests(struct kvm_vcpu *vcpu)
>  	return r;
>  }
>  
> -int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
> +int kvmppc_vcpu_run(struct kvm_vcpu *vcpu)
>  {
> +	struct kvm_run *run = vcpu->run;
>  	int ret, s;
>  	struct debug_reg debug;
>  
>  	if (!vcpu->arch.sane) {
> -		kvm_run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
> +		run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
>  		return -EINVAL;
>  	}
>  
> @@ -778,7 +779,7 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  	vcpu->arch.pgdir = vcpu->kvm->mm->pgd;
>  	kvmppc_fix_ee_before_entry();
>  
> -	ret = __kvmppc_vcpu_run(kvm_run, vcpu);
> +	ret = __kvmppc_vcpu_run(run, vcpu);
>  
>  	/* No need for guest_exit. It's done in handle_exit.
>  	   We also get here with interrupts enabled. */
> @@ -800,11 +801,11 @@ int kvmppc_vcpu_run(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  	return ret;
>  }
>  
> -static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
> +static int emulation_exit(struct kvm_vcpu *vcpu)
>  {
>  	enum emulation_result er;
>  
> -	er = kvmppc_emulate_instruction(run, vcpu);
> +	er = kvmppc_emulate_instruction(vcpu);
>  	switch (er) {
>  	case EMULATE_DONE:
>  		/* don't overwrite subtypes, just account kvm_stats */
> @@ -821,8 +822,8 @@ static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  		       __func__, vcpu->arch.regs.nip, vcpu->arch.last_inst);
>  		/* For debugging, encode the failing instruction and
>  		 * report it to userspace. */
> -		run->hw.hardware_exit_reason = ~0ULL << 32;
> -		run->hw.hardware_exit_reason |= vcpu->arch.last_inst;
> +		vcpu->run->hw.hardware_exit_reason = ~0ULL << 32;
> +		vcpu->run->hw.hardware_exit_reason |= vcpu->arch.last_inst;
>  		kvmppc_core_queue_program(vcpu, ESR_PIL);
>  		return RESUME_HOST;
>  
> @@ -834,8 +835,9 @@ static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  	}
>  }
>  
> -static int kvmppc_handle_debug(struct kvm_run *run, struct kvm_vcpu *vcpu)
> +static int kvmppc_handle_debug(struct kvm_vcpu *vcpu)
>  {
> +	struct kvm_run *run = vcpu->run;
>  	struct debug_reg *dbg_reg = &(vcpu->arch.dbg_reg);
>  	u32 dbsr = vcpu->arch.dbsr;
>  
> @@ -954,7 +956,7 @@ static void kvmppc_restart_interrupt(struct kvm_vcpu *vcpu,
>  	}
>  }
>  
> -static int kvmppc_resume_inst_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +static int kvmppc_resume_inst_load(struct kvm_vcpu *vcpu,
>  				  enum emulation_result emulated, u32 last_inst)
>  {
>  	switch (emulated) {
> @@ -966,8 +968,8 @@ static int kvmppc_resume_inst_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  		       __func__, vcpu->arch.regs.nip);
>  		/* For debugging, encode the failing instruction and
>  		 * report it to userspace. */
> -		run->hw.hardware_exit_reason = ~0ULL << 32;
> -		run->hw.hardware_exit_reason |= last_inst;
> +		vcpu->run->hw.hardware_exit_reason = ~0ULL << 32;
> +		vcpu->run->hw.hardware_exit_reason |= last_inst;
>  		kvmppc_core_queue_program(vcpu, ESR_PIL);
>  		return RESUME_HOST;
>  
> @@ -1024,7 +1026,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	run->ready_for_interrupt_injection = 1;
>  
>  	if (emulated != EMULATE_DONE) {
> -		r = kvmppc_resume_inst_load(run, vcpu, emulated, last_inst);
> +		r = kvmppc_resume_inst_load(vcpu, emulated, last_inst);
>  		goto out;
>  	}
>  
> @@ -1084,7 +1086,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  		break;
>  
>  	case BOOKE_INTERRUPT_HV_PRIV:
> -		r = emulation_exit(run, vcpu);
> +		r = emulation_exit(vcpu);
>  		break;
>  
>  	case BOOKE_INTERRUPT_PROGRAM:
> @@ -1094,7 +1096,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			 * We are here because of an SW breakpoint instr,
>  			 * so lets return to host to handle.
>  			 */
> -			r = kvmppc_handle_debug(run, vcpu);
> +			r = kvmppc_handle_debug(vcpu);
>  			run->exit_reason = KVM_EXIT_DEBUG;
>  			kvmppc_account_exit(vcpu, DEBUG_EXITS);
>  			break;
> @@ -1115,7 +1117,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			break;
>  		}
>  
> -		r = emulation_exit(run, vcpu);
> +		r = emulation_exit(vcpu);
>  		break;
>  
>  	case BOOKE_INTERRUPT_FP_UNAVAIL:
> @@ -1282,7 +1284,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			 * actually RAM. */
>  			vcpu->arch.paddr_accessed = gpaddr;
>  			vcpu->arch.vaddr_accessed = eaddr;
> -			r = kvmppc_emulate_mmio(run, vcpu);
> +			r = kvmppc_emulate_mmio(vcpu);
>  			kvmppc_account_exit(vcpu, MMIO_EXITS);
>  		}
>  
> @@ -1333,7 +1335,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	}
>  
>  	case BOOKE_INTERRUPT_DEBUG: {
> -		r = kvmppc_handle_debug(run, vcpu);
> +		r = kvmppc_handle_debug(vcpu);
>  		if (r == RESUME_HOST)
>  			run->exit_reason = KVM_EXIT_DEBUG;
>  		kvmppc_account_exit(vcpu, DEBUG_EXITS);
> diff --git a/arch/powerpc/kvm/booke.h b/arch/powerpc/kvm/booke.h
> index 65b4d337d337..be9da96d9f06 100644
> --- a/arch/powerpc/kvm/booke.h
> +++ b/arch/powerpc/kvm/booke.h
> @@ -70,7 +70,7 @@ void kvmppc_set_tcr(struct kvm_vcpu *vcpu, u32 new_tcr);
>  void kvmppc_set_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
>  void kvmppc_clr_tsr_bits(struct kvm_vcpu *vcpu, u32 tsr_bits);
>  
> -int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +int kvmppc_booke_emulate_op(struct kvm_vcpu *vcpu,
>                              unsigned int inst, int *advance);
>  int kvmppc_booke_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val);
>  int kvmppc_booke_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val);
> @@ -94,16 +94,12 @@ enum int_class {
>  
>  void kvmppc_set_pending_interrupt(struct kvm_vcpu *vcpu, enum int_class type);
>  
> -extern int kvmppc_core_emulate_op_e500(struct kvm_run *run,
> -				       struct kvm_vcpu *vcpu,
> +extern int kvmppc_core_emulate_op_e500(struct kvm_vcpu *vcpu,
>  				       unsigned int inst, int *advance);
>  extern int kvmppc_core_emulate_mtspr_e500(struct kvm_vcpu *vcpu, int sprn,
>  					  ulong spr_val);
>  extern int kvmppc_core_emulate_mfspr_e500(struct kvm_vcpu *vcpu, int sprn,
>  					  ulong *spr_val);
> -extern int kvmppc_core_emulate_op_e500(struct kvm_run *run,
> -				       struct kvm_vcpu *vcpu,
> -				       unsigned int inst, int *advance);
>  extern int kvmppc_core_emulate_mtspr_e500(struct kvm_vcpu *vcpu, int sprn,
>  					  ulong spr_val);
>  extern int kvmppc_core_emulate_mfspr_e500(struct kvm_vcpu *vcpu, int sprn,
> diff --git a/arch/powerpc/kvm/booke_emulate.c b/arch/powerpc/kvm/booke_emulate.c
> index 689ff5f90e9e..d8d38aca71bd 100644
> --- a/arch/powerpc/kvm/booke_emulate.c
> +++ b/arch/powerpc/kvm/booke_emulate.c
> @@ -39,7 +39,7 @@ static void kvmppc_emul_rfci(struct kvm_vcpu *vcpu)
>  	kvmppc_set_msr(vcpu, vcpu->arch.csrr1);
>  }
>  
> -int kvmppc_booke_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +int kvmppc_booke_emulate_op(struct kvm_vcpu *vcpu,
>                              unsigned int inst, int *advance)
>  {
>  	int emulated = EMULATE_DONE;
> diff --git a/arch/powerpc/kvm/e500_emulate.c b/arch/powerpc/kvm/e500_emulate.c
> index 3d0d3ec5be96..64eb833e9f02 100644
> --- a/arch/powerpc/kvm/e500_emulate.c
> +++ b/arch/powerpc/kvm/e500_emulate.c
> @@ -83,16 +83,16 @@ static int kvmppc_e500_emul_msgsnd(struct kvm_vcpu *vcpu, int rb)
>  }
>  #endif
>  
> -static int kvmppc_e500_emul_ehpriv(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +static int kvmppc_e500_emul_ehpriv(struct kvm_vcpu *vcpu,
>  				   unsigned int inst, int *advance)
>  {
>  	int emulated = EMULATE_DONE;
>  
>  	switch (get_oc(inst)) {
>  	case EHPRIV_OC_DEBUG:
> -		run->exit_reason = KVM_EXIT_DEBUG;
> -		run->debug.arch.address = vcpu->arch.regs.nip;
> -		run->debug.arch.status = 0;
> +		vcpu->run->exit_reason = KVM_EXIT_DEBUG;
> +		vcpu->run->debug.arch.address = vcpu->arch.regs.nip;
> +		vcpu->run->debug.arch.status = 0;
>  		kvmppc_account_exit(vcpu, DEBUG_EXITS);
>  		emulated = EMULATE_EXIT_USER;
>  		*advance = 0;
> @@ -125,7 +125,7 @@ static int kvmppc_e500_emul_mftmr(struct kvm_vcpu *vcpu, unsigned int inst,
>  	return EMULATE_FAIL;
>  }
>  
> -int kvmppc_core_emulate_op_e500(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +int kvmppc_core_emulate_op_e500(struct kvm_vcpu *vcpu,
>  				unsigned int inst, int *advance)
>  {
>  	int emulated = EMULATE_DONE;
> @@ -182,8 +182,7 @@ int kvmppc_core_emulate_op_e500(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			break;
>  
>  		case XOP_EHPRIV:
> -			emulated = kvmppc_e500_emul_ehpriv(run, vcpu, inst,
> -							   advance);
> +			emulated = kvmppc_e500_emul_ehpriv(vcpu, inst, advance);
>  			break;
>  
>  		default:
> @@ -197,7 +196,7 @@ int kvmppc_core_emulate_op_e500(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	}
>  
>  	if (emulated == EMULATE_FAIL)
> -		emulated = kvmppc_booke_emulate_op(run, vcpu, inst, advance);
> +		emulated = kvmppc_booke_emulate_op(vcpu, inst, advance);
>  
>  	return emulated;
>  }
> diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c
> index 6fca38ca791f..ee1147c98cd8 100644
> --- a/arch/powerpc/kvm/emulate.c
> +++ b/arch/powerpc/kvm/emulate.c
> @@ -191,7 +191,7 @@ static int kvmppc_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt)
>  
>  /* XXX Should probably auto-generate instruction decoding for a particular core
>   * from opcode tables in the future. */
> -int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
> +int kvmppc_emulate_instruction(struct kvm_vcpu *vcpu)
>  {
>  	u32 inst;
>  	int rs, rt, sprn;
> @@ -270,9 +270,9 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  		 * these are illegal instructions.
>  		 */
>  		if (inst == KVMPPC_INST_SW_BREAKPOINT) {
> -			run->exit_reason = KVM_EXIT_DEBUG;
> -			run->debug.arch.status = 0;
> -			run->debug.arch.address = kvmppc_get_pc(vcpu);
> +			vcpu->run->exit_reason = KVM_EXIT_DEBUG;
> +			vcpu->run->debug.arch.status = 0;
> +			vcpu->run->debug.arch.address = kvmppc_get_pc(vcpu);
>  			emulated = EMULATE_EXIT_USER;
>  			advance = 0;
>  		} else
> @@ -285,7 +285,7 @@ int kvmppc_emulate_instruction(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  	}
>  
>  	if (emulated == EMULATE_FAIL) {
> -		emulated = vcpu->kvm->arch.kvm_ops->emulate_op(run, vcpu, inst,
> +		emulated = vcpu->kvm->arch.kvm_ops->emulate_op(vcpu, inst,
>  							       &advance);
>  		if (emulated == EMULATE_AGAIN) {
>  			advance = 0;
> diff --git a/arch/powerpc/kvm/emulate_loadstore.c b/arch/powerpc/kvm/emulate_loadstore.c
> index 1139bc56e004..e8a47c84d77d 100644
> --- a/arch/powerpc/kvm/emulate_loadstore.c
> +++ b/arch/powerpc/kvm/emulate_loadstore.c
> @@ -71,7 +71,6 @@ static bool kvmppc_check_altivec_disabled(struct kvm_vcpu *vcpu)
>   */
>  int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
>  {
> -	struct kvm_run *run = vcpu->run;
>  	u32 inst;
>  	enum emulation_result emulated = EMULATE_FAIL;
>  	int advance = 1;
> @@ -104,10 +103,10 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
>  			int instr_byte_swap = op.type & BYTEREV;
>  
>  			if (op.type & SIGNEXT)
> -				emulated = kvmppc_handle_loads(run, vcpu,
> +				emulated = kvmppc_handle_loads(vcpu,
>  						op.reg, size, !instr_byte_swap);
>  			else
> -				emulated = kvmppc_handle_load(run, vcpu,
> +				emulated = kvmppc_handle_load(vcpu,
>  						op.reg, size, !instr_byte_swap);
>  
>  			if ((op.type & UPDATE) && (emulated != EMULATE_FAIL))
> @@ -124,10 +123,10 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
>  				vcpu->arch.mmio_sp64_extend = 1;
>  
>  			if (op.type & SIGNEXT)
> -				emulated = kvmppc_handle_loads(run, vcpu,
> +				emulated = kvmppc_handle_loads(vcpu,
>  					     KVM_MMIO_REG_FPR|op.reg, size, 1);
>  			else
> -				emulated = kvmppc_handle_load(run, vcpu,
> +				emulated = kvmppc_handle_load(vcpu,
>  					     KVM_MMIO_REG_FPR|op.reg, size, 1);
>  
>  			if ((op.type & UPDATE) && (emulated != EMULATE_FAIL))
> @@ -164,12 +163,12 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
>  
>  			if (size == 16) {
>  				vcpu->arch.mmio_vmx_copy_nums = 2;
> -				emulated = kvmppc_handle_vmx_load(run,
> -						vcpu, KVM_MMIO_REG_VMX|op.reg,
> +				emulated = kvmppc_handle_vmx_load(vcpu,
> +						KVM_MMIO_REG_VMX|op.reg,
>  						8, 1);
>  			} else {
>  				vcpu->arch.mmio_vmx_copy_nums = 1;
> -				emulated = kvmppc_handle_vmx_load(run, vcpu,
> +				emulated = kvmppc_handle_vmx_load(vcpu,
>  						KVM_MMIO_REG_VMX|op.reg,
>  						size, 1);
>  			}
> @@ -217,7 +216,7 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
>  				io_size_each = op.element_size;
>  			}
>  
> -			emulated = kvmppc_handle_vsx_load(run, vcpu,
> +			emulated = kvmppc_handle_vsx_load(vcpu,
>  					KVM_MMIO_REG_VSX|op.reg, io_size_each,
>  					1, op.type & SIGNEXT);
>  			break;
> @@ -227,8 +226,7 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
>  			/* if need byte reverse, op.val has been reversed by
>  			 * analyse_instr().
>  			 */
> -			emulated = kvmppc_handle_store(run, vcpu, op.val,
> -					size, 1);
> +			emulated = kvmppc_handle_store(vcpu, op.val, size, 1);
>  
>  			if ((op.type & UPDATE) && (emulated != EMULATE_FAIL))
>  				kvmppc_set_gpr(vcpu, op.update_reg, op.ea);
> @@ -250,7 +248,7 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
>  			if (op.type & FPCONV)
>  				vcpu->arch.mmio_sp64_extend = 1;
>  
> -			emulated = kvmppc_handle_store(run, vcpu,
> +			emulated = kvmppc_handle_store(vcpu,
>  					VCPU_FPR(vcpu, op.reg), size, 1);
>  
>  			if ((op.type & UPDATE) && (emulated != EMULATE_FAIL))
> @@ -290,12 +288,12 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
>  
>  			if (size == 16) {
>  				vcpu->arch.mmio_vmx_copy_nums = 2;
> -				emulated = kvmppc_handle_vmx_store(run,
> -						vcpu, op.reg, 8, 1);
> +				emulated = kvmppc_handle_vmx_store(vcpu,
> +						op.reg, 8, 1);
>  			} else {
>  				vcpu->arch.mmio_vmx_copy_nums = 1;
> -				emulated = kvmppc_handle_vmx_store(run,
> -						vcpu, op.reg, size, 1);
> +				emulated = kvmppc_handle_vmx_store(vcpu,
> +						op.reg, size, 1);
>  			}
>  
>  			break;
> @@ -338,7 +336,7 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
>  				io_size_each = op.element_size;
>  			}
>  
> -			emulated = kvmppc_handle_vsx_store(run, vcpu,
> +			emulated = kvmppc_handle_vsx_store(vcpu,
>  					op.reg, io_size_each, 1);
>  			break;
>  		}
> diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c
> index 7e24691e138a..de4c317ad5f1 100644
> --- a/arch/powerpc/kvm/powerpc.c
> +++ b/arch/powerpc/kvm/powerpc.c
> @@ -279,7 +279,7 @@ int kvmppc_sanity_check(struct kvm_vcpu *vcpu)
>  }
>  EXPORT_SYMBOL_GPL(kvmppc_sanity_check);
>  
> -int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu)
> +int kvmppc_emulate_mmio(struct kvm_vcpu *vcpu)
>  {
>  	enum emulation_result er;
>  	int r;
> @@ -295,7 +295,7 @@ int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu)
>  		r = RESUME_GUEST;
>  		break;
>  	case EMULATE_DO_MMIO:
> -		run->exit_reason = KVM_EXIT_MMIO;
> +		vcpu->run->exit_reason = KVM_EXIT_MMIO;
>  		/* We must reload nonvolatiles because "update" load/store
>  		 * instructions modify register state. */
>  		/* Future optimization: only reload non-volatiles if they were
> @@ -1106,9 +1106,9 @@ static inline u32 dp_to_sp(u64 fprd)
>  #define dp_to_sp(x)	(x)
>  #endif /* CONFIG_PPC_FPU */
>  
> -static void kvmppc_complete_mmio_load(struct kvm_vcpu *vcpu,
> -                                      struct kvm_run *run)
> +static void kvmppc_complete_mmio_load(struct kvm_vcpu *vcpu)
>  {
> +	struct kvm_run *run = vcpu->run;
>  	u64 uninitialized_var(gpr);
>  
>  	if (run->mmio.len > sizeof(gpr)) {
> @@ -1218,10 +1218,11 @@ static void kvmppc_complete_mmio_load(struct kvm_vcpu *vcpu,
>  	}
>  }
>  
> -static int __kvmppc_handle_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +static int __kvmppc_handle_load(struct kvm_vcpu *vcpu,
>  				unsigned int rt, unsigned int bytes,
>  				int is_default_endian, int sign_extend)
>  {
> +	struct kvm_run *run = vcpu->run;
>  	int idx, ret;
>  	bool host_swabbed;
>  
> @@ -1255,7 +1256,7 @@ static int __kvmppc_handle_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	srcu_read_unlock(&vcpu->kvm->srcu, idx);
>  
>  	if (!ret) {
> -		kvmppc_complete_mmio_load(vcpu, run);
> +		kvmppc_complete_mmio_load(vcpu);
>  		vcpu->mmio_needed = 0;
>  		return EMULATE_DONE;
>  	}
> @@ -1263,24 +1264,24 @@ static int __kvmppc_handle_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	return EMULATE_DO_MMIO;
>  }
>  
> -int kvmppc_handle_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +int kvmppc_handle_load(struct kvm_vcpu *vcpu,
>  		       unsigned int rt, unsigned int bytes,
>  		       int is_default_endian)
>  {
> -	return __kvmppc_handle_load(run, vcpu, rt, bytes, is_default_endian, 0);
> +	return __kvmppc_handle_load(vcpu, rt, bytes, is_default_endian, 0);
>  }
>  EXPORT_SYMBOL_GPL(kvmppc_handle_load);
>  
>  /* Same as above, but sign extends */
> -int kvmppc_handle_loads(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +int kvmppc_handle_loads(struct kvm_vcpu *vcpu,
>  			unsigned int rt, unsigned int bytes,
>  			int is_default_endian)
>  {
> -	return __kvmppc_handle_load(run, vcpu, rt, bytes, is_default_endian, 1);
> +	return __kvmppc_handle_load(vcpu, rt, bytes, is_default_endian, 1);
>  }
>  
>  #ifdef CONFIG_VSX
> -int kvmppc_handle_vsx_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +int kvmppc_handle_vsx_load(struct kvm_vcpu *vcpu,
>  			unsigned int rt, unsigned int bytes,
>  			int is_default_endian, int mmio_sign_extend)
>  {
> @@ -1291,13 +1292,13 @@ int kvmppc_handle_vsx_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  		return EMULATE_FAIL;
>  
>  	while (vcpu->arch.mmio_vsx_copy_nums) {
> -		emulated = __kvmppc_handle_load(run, vcpu, rt, bytes,
> +		emulated = __kvmppc_handle_load(vcpu, rt, bytes,
>  			is_default_endian, mmio_sign_extend);
>  
>  		if (emulated != EMULATE_DONE)
>  			break;
>  
> -		vcpu->arch.paddr_accessed += run->mmio.len;
> +		vcpu->arch.paddr_accessed += vcpu->run->mmio.len;
>  
>  		vcpu->arch.mmio_vsx_copy_nums--;
>  		vcpu->arch.mmio_vsx_offset++;
> @@ -1306,9 +1307,10 @@ int kvmppc_handle_vsx_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  }
>  #endif /* CONFIG_VSX */
>  
> -int kvmppc_handle_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +int kvmppc_handle_store(struct kvm_vcpu *vcpu,
>  			u64 val, unsigned int bytes, int is_default_endian)
>  {
> +	struct kvm_run *run = vcpu->run;
>  	void *data = run->mmio.data;
>  	int idx, ret;
>  	bool host_swabbed;
> @@ -1422,7 +1424,7 @@ static inline int kvmppc_get_vsr_data(struct kvm_vcpu *vcpu, int rs, u64 *val)
>  	return result;
>  }
>  
> -int kvmppc_handle_vsx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +int kvmppc_handle_vsx_store(struct kvm_vcpu *vcpu,
>  			int rs, unsigned int bytes, int is_default_endian)
>  {
>  	u64 val;
> @@ -1438,13 +1440,13 @@ int kvmppc_handle_vsx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  		if (kvmppc_get_vsr_data(vcpu, rs, &val) == -1)
>  			return EMULATE_FAIL;
>  
> -		emulated = kvmppc_handle_store(run, vcpu,
> +		emulated = kvmppc_handle_store(vcpu,
>  			 val, bytes, is_default_endian);
>  
>  		if (emulated != EMULATE_DONE)
>  			break;
>  
> -		vcpu->arch.paddr_accessed += run->mmio.len;
> +		vcpu->arch.paddr_accessed += vcpu->run->mmio.len;
>  
>  		vcpu->arch.mmio_vsx_copy_nums--;
>  		vcpu->arch.mmio_vsx_offset++;
> @@ -1453,19 +1455,19 @@ int kvmppc_handle_vsx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	return emulated;
>  }
>  
> -static int kvmppc_emulate_mmio_vsx_loadstore(struct kvm_vcpu *vcpu,
> -			struct kvm_run *run)
> +static int kvmppc_emulate_mmio_vsx_loadstore(struct kvm_vcpu *vcpu)
>  {
> +	struct kvm_run *run = vcpu->run;
>  	enum emulation_result emulated = EMULATE_FAIL;
>  	int r;
>  
>  	vcpu->arch.paddr_accessed += run->mmio.len;
>  
>  	if (!vcpu->mmio_is_write) {
> -		emulated = kvmppc_handle_vsx_load(run, vcpu, vcpu->arch.io_gpr,
> +		emulated = kvmppc_handle_vsx_load(vcpu, vcpu->arch.io_gpr,
>  			 run->mmio.len, 1, vcpu->arch.mmio_sign_extend);
>  	} else {
> -		emulated = kvmppc_handle_vsx_store(run, vcpu,
> +		emulated = kvmppc_handle_vsx_store(vcpu,
>  			 vcpu->arch.io_gpr, run->mmio.len, 1);
>  	}
>  
> @@ -1489,7 +1491,7 @@ static int kvmppc_emulate_mmio_vsx_loadstore(struct kvm_vcpu *vcpu,
>  #endif /* CONFIG_VSX */
>  
>  #ifdef CONFIG_ALTIVEC
> -int kvmppc_handle_vmx_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +int kvmppc_handle_vmx_load(struct kvm_vcpu *vcpu,
>  		unsigned int rt, unsigned int bytes, int is_default_endian)
>  {
>  	enum emulation_result emulated = EMULATE_DONE;
> @@ -1498,13 +1500,13 @@ int kvmppc_handle_vmx_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  		return EMULATE_FAIL;
>  
>  	while (vcpu->arch.mmio_vmx_copy_nums) {
> -		emulated = __kvmppc_handle_load(run, vcpu, rt, bytes,
> +		emulated = __kvmppc_handle_load(vcpu, rt, bytes,
>  				is_default_endian, 0);
>  
>  		if (emulated != EMULATE_DONE)
>  			break;
>  
> -		vcpu->arch.paddr_accessed += run->mmio.len;
> +		vcpu->arch.paddr_accessed += vcpu->run->mmio.len;
>  		vcpu->arch.mmio_vmx_copy_nums--;
>  		vcpu->arch.mmio_vmx_offset++;
>  	}
> @@ -1584,7 +1586,7 @@ int kvmppc_get_vmx_byte(struct kvm_vcpu *vcpu, int index, u64 *val)
>  	return result;
>  }
>  
> -int kvmppc_handle_vmx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
> +int kvmppc_handle_vmx_store(struct kvm_vcpu *vcpu,
>  		unsigned int rs, unsigned int bytes, int is_default_endian)
>  {
>  	u64 val = 0;
> @@ -1619,12 +1621,12 @@ int kvmppc_handle_vmx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  			return EMULATE_FAIL;
>  		}
>  
> -		emulated = kvmppc_handle_store(run, vcpu, val, bytes,
> +		emulated = kvmppc_handle_store(vcpu, val, bytes,
>  				is_default_endian);
>  		if (emulated != EMULATE_DONE)
>  			break;
>  
> -		vcpu->arch.paddr_accessed += run->mmio.len;
> +		vcpu->arch.paddr_accessed += vcpu->run->mmio.len;
>  		vcpu->arch.mmio_vmx_copy_nums--;
>  		vcpu->arch.mmio_vmx_offset++;
>  	}
> @@ -1632,19 +1634,19 @@ int kvmppc_handle_vmx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
>  	return emulated;
>  }
>  
> -static int kvmppc_emulate_mmio_vmx_loadstore(struct kvm_vcpu *vcpu,
> -		struct kvm_run *run)
> +static int kvmppc_emulate_mmio_vmx_loadstore(struct kvm_vcpu *vcpu)
>  {
> +	struct kvm_run *run = vcpu->run;
>  	enum emulation_result emulated = EMULATE_FAIL;
>  	int r;
>  
>  	vcpu->arch.paddr_accessed += run->mmio.len;
>  
>  	if (!vcpu->mmio_is_write) {
> -		emulated = kvmppc_handle_vmx_load(run, vcpu,
> +		emulated = kvmppc_handle_vmx_load(vcpu,
>  				vcpu->arch.io_gpr, run->mmio.len, 1);
>  	} else {
> -		emulated = kvmppc_handle_vmx_store(run, vcpu,
> +		emulated = kvmppc_handle_vmx_store(vcpu,
>  				vcpu->arch.io_gpr, run->mmio.len, 1);
>  	}
>  
> @@ -1774,7 +1776,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
>  	if (vcpu->mmio_needed) {
>  		vcpu->mmio_needed = 0;
>  		if (!vcpu->mmio_is_write)
> -			kvmppc_complete_mmio_load(vcpu, run);
> +			kvmppc_complete_mmio_load(vcpu);
>  #ifdef CONFIG_VSX
>  		if (vcpu->arch.mmio_vsx_copy_nums > 0) {
>  			vcpu->arch.mmio_vsx_copy_nums--;
> @@ -1782,7 +1784,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
>  		}
>  
>  		if (vcpu->arch.mmio_vsx_copy_nums > 0) {
> -			r = kvmppc_emulate_mmio_vsx_loadstore(vcpu, run);
> +			r = kvmppc_emulate_mmio_vsx_loadstore(vcpu);
>  			if (r == RESUME_HOST) {
>  				vcpu->mmio_needed = 1;
>  				goto out;
> @@ -1796,7 +1798,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
>  		}
>  
>  		if (vcpu->arch.mmio_vmx_copy_nums > 0) {
> -			r = kvmppc_emulate_mmio_vmx_loadstore(vcpu, run);
> +			r = kvmppc_emulate_mmio_vmx_loadstore(vcpu);
>  			if (r == RESUME_HOST) {
>  				vcpu->mmio_needed = 1;
>  				goto out;
> @@ -1829,7 +1831,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
>  	if (run->immediate_exit)
>  		r = -EINTR;
>  	else
> -		r = kvmppc_vcpu_run(run, vcpu);
> +		r = kvmppc_vcpu_run(vcpu);
>  
>  	kvm_sigset_deactivate(vcpu);
>  
> diff --git a/arch/powerpc/kvm/trace_hv.h b/arch/powerpc/kvm/trace_hv.h
> index 8a1e3b0047f1..4a61a971c34e 100644
> --- a/arch/powerpc/kvm/trace_hv.h
> +++ b/arch/powerpc/kvm/trace_hv.h
> @@ -472,9 +472,9 @@ TRACE_EVENT(kvmppc_run_vcpu_enter,
>  );
>  
>  TRACE_EVENT(kvmppc_run_vcpu_exit,
> -	TP_PROTO(struct kvm_vcpu *vcpu, struct kvm_run *run),
> +	TP_PROTO(struct kvm_vcpu *vcpu),
>  
> -	TP_ARGS(vcpu, run),
> +	TP_ARGS(vcpu),
>  
>  	TP_STRUCT__entry(
>  		__field(int,		vcpu_id)
> @@ -484,7 +484,7 @@ TRACE_EVENT(kvmppc_run_vcpu_exit,
>  
>  	TP_fast_assign(
>  		__entry->vcpu_id  = vcpu->vcpu_id;
> -		__entry->exit     = run->exit_reason;
> +		__entry->exit     = vcpu->run->exit_reason;
>  		__entry->ret      = vcpu->arch.ret;
>  	),

'git grep kvm_run arch/powerpc/kvm/' tells me the result is correct so
in case this even compiles, feel free to add

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

-- 
Vitaly


^ permalink raw reply

* Re: [PATCH v4 3/7] KVM: PPC: Remove redundant kvm_run from vcpu_arch
From: Vitaly Kuznetsov @ 2020-04-29 12:23 UTC (permalink / raw)
  To: Tianjia Zhang
  Cc: christoffer.dall, wanpengli, kvm, david, heiko.carstens, peterx,
	linux-kernel, hpa, kvmarm, linux-s390, frankja, chenhuacai, joro,
	x86, borntraeger, mingo, julien.thierry.kdev, thuth, gor,
	suzuki.poulose, kvm-ppc, bp, tglx, linux-arm-kernel, jmattson,
	tsbogend, tianjia.zhang, cohuck, linux-mips,
	sean.j.christopherson, james.morse, maz, pbonzini, linuxppc-dev
In-Reply-To: <20200427043514.16144-4-tianjia.zhang@linux.alibaba.com>

Tianjia Zhang <tianjia.zhang@linux.alibaba.com> writes:

> The 'kvm_run' field already exists in the 'vcpu' structure, which
> is the same structure as the 'kvm_run' in the 'vcpu_arch' and
> should be deleted.
>
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> ---
>  arch/powerpc/include/asm/kvm_host.h | 1 -
>  arch/powerpc/kvm/book3s_hv.c        | 6 ++----
>  arch/powerpc/kvm/book3s_hv_nested.c | 3 +--
>  3 files changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
> index 1dc63101ffe1..2745ff8faa01 100644
> --- a/arch/powerpc/include/asm/kvm_host.h
> +++ b/arch/powerpc/include/asm/kvm_host.h
> @@ -795,7 +795,6 @@ struct kvm_vcpu_arch {
>  	struct mmio_hpte_cache_entry *pgfault_cache;
>  
>  	struct task_struct *run_task;
> -	struct kvm_run *kvm_run;
>  
>  	spinlock_t vpa_update_lock;
>  	struct kvmppc_vpa vpa;
> diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c
> index 93493f0cbfe8..413ea2dcb10c 100644
> --- a/arch/powerpc/kvm/book3s_hv.c
> +++ b/arch/powerpc/kvm/book3s_hv.c
> @@ -2934,7 +2934,7 @@ static void post_guest_process(struct kvmppc_vcore *vc, bool is_master)
>  
>  		ret = RESUME_GUEST;
>  		if (vcpu->arch.trap)
> -			ret = kvmppc_handle_exit_hv(vcpu->arch.kvm_run, vcpu,
> +			ret = kvmppc_handle_exit_hv(vcpu->run, vcpu,
>  						    vcpu->arch.run_task);
>  
>  		vcpu->arch.ret = ret;
> @@ -3920,7 +3920,6 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  	spin_lock(&vc->lock);
>  	vcpu->arch.ceded = 0;
>  	vcpu->arch.run_task = current;
> -	vcpu->arch.kvm_run = kvm_run;
>  	vcpu->arch.stolen_logged = vcore_stolen_time(vc, mftb());
>  	vcpu->arch.state = KVMPPC_VCPU_RUNNABLE;
>  	vcpu->arch.busy_preempt = TB_NIL;
> @@ -3973,7 +3972,7 @@ static int kvmppc_run_vcpu(struct kvm_run *kvm_run, struct kvm_vcpu *vcpu)
>  			if (signal_pending(v->arch.run_task)) {
>  				kvmppc_remove_runnable(vc, v);
>  				v->stat.signal_exits++;
> -				v->arch.kvm_run->exit_reason = KVM_EXIT_INTR;
> +				v->run->exit_reason = KVM_EXIT_INTR;
>  				v->arch.ret = -EINTR;
>  				wake_up(&v->arch.cpu_run);
>  			}
> @@ -4049,7 +4048,6 @@ int kvmhv_run_single_vcpu(struct kvm_run *kvm_run,
>  	vc = vcpu->arch.vcore;
>  	vcpu->arch.ceded = 0;
>  	vcpu->arch.run_task = current;
> -	vcpu->arch.kvm_run = kvm_run;
>  	vcpu->arch.stolen_logged = vcore_stolen_time(vc, mftb());
>  	vcpu->arch.state = KVMPPC_VCPU_RUNNABLE;
>  	vcpu->arch.busy_preempt = TB_NIL;
> diff --git a/arch/powerpc/kvm/book3s_hv_nested.c b/arch/powerpc/kvm/book3s_hv_nested.c
> index dc97e5be76f6..5a3987f3ebf3 100644
> --- a/arch/powerpc/kvm/book3s_hv_nested.c
> +++ b/arch/powerpc/kvm/book3s_hv_nested.c
> @@ -290,8 +290,7 @@ long kvmhv_enter_nested_guest(struct kvm_vcpu *vcpu)
>  			r = RESUME_HOST;
>  			break;
>  		}
> -		r = kvmhv_run_single_vcpu(vcpu->arch.kvm_run, vcpu, hdec_exp,
> -					  lpcr);
> +		r = kvmhv_run_single_vcpu(vcpu->run, vcpu, hdec_exp, lpcr);
>  	} while (is_kvmppc_resume_guest(r));
>  
>  	/* save L2 state for return */

FWIW,

Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>

-- 
Vitaly


^ permalink raw reply

* Re: [PATCH v2 3/3] mm/page_alloc: Keep memoryless cpuless node 0 offline
From: Michal Hocko @ 2020-04-29 12:22 UTC (permalink / raw)
  To: Srikar Dronamraju
  Cc: Linus Torvalds, linux-kernel, linux-mm, Mel Gorman,
	Kirill A. Shutemov, Andrew Morton, linuxppc-dev,
	Christopher Lameter, Vlastimil Babka
In-Reply-To: <20200429014145.GD19958@linux.vnet.ibm.com>

On Wed 29-04-20 07:11:45, Srikar Dronamraju wrote:
> > > 
> > > By marking, N_ONLINE as NODE_MASK_NONE, lets stop assuming that Node 0 is
> > > always online.
> > > 
> > > ...
> > >
> > > --- a/mm/page_alloc.c
> > > +++ b/mm/page_alloc.c
> > > @@ -116,8 +116,10 @@ EXPORT_SYMBOL(latent_entropy);
> > >   */
> > >  nodemask_t node_states[NR_NODE_STATES] __read_mostly = {
> > >  	[N_POSSIBLE] = NODE_MASK_ALL,
> > > +#ifdef CONFIG_NUMA
> > > +	[N_ONLINE] = NODE_MASK_NONE,
> > > +#else
> > >  	[N_ONLINE] = { { [0] = 1UL } },
> > > -#ifndef CONFIG_NUMA
> > >  	[N_NORMAL_MEMORY] = { { [0] = 1UL } },
> > >  #ifdef CONFIG_HIGHMEM
> > >  	[N_HIGH_MEMORY] = { { [0] = 1UL } },
> > 
> > So on all other NUMA machines, when does node 0 get marked online?
> > 
> > This change means that for some time during boot, such machines will
> > now be running with node 0 marked as offline.  What are the
> > implications of this?  Will something break?
> 
> Till the nodes are detected, marking Node 0 as online tends to be redundant.
> Because the system doesn't know if its a NUMA or a non-NUMA system.
> Once we detect the nodes, we online them immediately. Hence I don't see any
> side-effects or negative implications of this change.
> 
> However if I am missing anything, please do let me know.
> 
> >From my part, I have tested this on
> 1. Non-NUMA Single node but CPUs and memory coming from zero node.
> 2. Non-NUMA Single node but CPUs and memory coming from non-zero node.
> 3. NUMA Multi node but with CPUs and memory from node 0.
> 4. NUMA Multi node but with no CPUs and memory from node 0.

Have you tested on something else than ppc? Each arch does the NUMA
setup separately and this is a big mess. E.g. x86 marks even memory less
nodes (see init_memory_less_node) as online.

Honestly I have hard time to evaluate the effect of this patch. It makes
some sense to assume all nodes offline before they get online but this
is a land mine territory.

I am also not sure what kind of problem this is going to address. You
have mentioned numa balancing without many details.
-- 
Michal Hocko
SUSE Labs

^ permalink raw reply

* [PATCH v2 20/20] docs/vm: update memory-models documentation
From: Mike Rapoport @ 2020-04-29 12:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
	Heiko Carstens, Michal Hocko, James E.J. Bottomley, Max Filippov,
	Guo Ren, linux-csky, linux-parisc, sparclinux, linux-hexagon,
	linux-riscv, Mike Rapoport, Greg Ungerer, linux-arch, linux-s390,
	linux-c6x-dev, Baoquan He, Jonathan Corbet, linux-sh,
	Helge Deller, x86, Russell King, Ley Foon Tan, Yoshinori Sato,
	Geert Uytterhoeven, linux-arm-kernel, Mark Salter, Matt Turner,
	linux-snps-arc, uclinux-h8-devel, linux-xtensa, linux-alpha,
	linux-um, linux-m68k, Tony Luck, Qian Cai, Greentime Hu,
	Paul Walmsley, Stafford Horne, Guan Xuetao, Hoan Tran,
	Michal Simek, Thomas Bogendoerfer, Brian Cain, Nick Hu, linux-mm,
	Vineet Gupta, linux-mips, openrisc, Richard Weinberger,
	Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200429121126.17989-1-rppt@kernel.org>

From: Mike Rapoport <rppt@linux.ibm.com>

to reflect the updates to free_area_init() family of functions.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 Documentation/vm/memory-model.rst | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/Documentation/vm/memory-model.rst b/Documentation/vm/memory-model.rst
index 58a12376b7df..91228044ed16 100644
--- a/Documentation/vm/memory-model.rst
+++ b/Documentation/vm/memory-model.rst
@@ -46,11 +46,10 @@ maps the entire physical memory. For most architectures, the holes
 have entries in the `mem_map` array. The `struct page` objects
 corresponding to the holes are never fully initialized.
 
-To allocate the `mem_map` array, architecture specific setup code
-should call :c:func:`free_area_init_node` function or its convenience
-wrapper :c:func:`free_area_init`. Yet, the mappings array is not
-usable until the call to :c:func:`memblock_free_all` that hands all
-the memory to the page allocator.
+To allocate the `mem_map` array, architecture specific setup code should
+call :c:func:`free_area_init` function. Yet, the mappings array is not
+usable until the call to :c:func:`memblock_free_all` that hands all the
+memory to the page allocator.
 
 If an architecture enables `CONFIG_ARCH_HAS_HOLES_MEMORYMODEL` option,
 it may free parts of the `mem_map` array that do not cover the
-- 
2.26.1


^ permalink raw reply related

* [PATCH v2 19/20] mm: simplify find_min_pfn_with_active_regions()
From: Mike Rapoport @ 2020-04-29 12:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
	Heiko Carstens, Michal Hocko, James E.J. Bottomley, Max Filippov,
	Guo Ren, linux-csky, linux-parisc, sparclinux, linux-hexagon,
	linux-riscv, Mike Rapoport, Greg Ungerer, linux-arch, linux-s390,
	linux-c6x-dev, Baoquan He, Jonathan Corbet, linux-sh,
	Helge Deller, x86, Russell King, Ley Foon Tan, Yoshinori Sato,
	Geert Uytterhoeven, linux-arm-kernel, Mark Salter, Matt Turner,
	linux-snps-arc, uclinux-h8-devel, linux-xtensa, linux-alpha,
	linux-um, linux-m68k, Tony Luck, Qian Cai, Greentime Hu,
	Paul Walmsley, Stafford Horne, Guan Xuetao, Hoan Tran,
	Michal Simek, Thomas Bogendoerfer, Brian Cain, Nick Hu, linux-mm,
	Vineet Gupta, linux-mips, openrisc, Richard Weinberger,
	Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200429121126.17989-1-rppt@kernel.org>

From: Mike Rapoport <rppt@linux.ibm.com>

The find_min_pfn_with_active_regions() calls find_min_pfn_for_node() with
nid parameter set to MAX_NUMNODES. This makes the find_min_pfn_for_node()
traverse all memblock memory regions although the first PFN in the system
can be easily found with memblock_start_of_DRAM().

Use memblock_start_of_DRAM() in find_min_pfn_with_active_regions() and drop
now unused find_min_pfn_for_node().

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 mm/page_alloc.c | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 30d171451d4c..b990e9734474 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7045,24 +7045,6 @@ unsigned long __init node_map_pfn_alignment(void)
 	return ~accl_mask + 1;
 }
 
-/* Find the lowest pfn for a node */
-static unsigned long __init find_min_pfn_for_node(int nid)
-{
-	unsigned long min_pfn = ULONG_MAX;
-	unsigned long start_pfn;
-	int i;
-
-	for_each_mem_pfn_range(i, nid, &start_pfn, NULL, NULL)
-		min_pfn = min(min_pfn, start_pfn);
-
-	if (min_pfn == ULONG_MAX) {
-		pr_warn("Could not find start_pfn for node %d\n", nid);
-		return 0;
-	}
-
-	return min_pfn;
-}
-
 /**
  * find_min_pfn_with_active_regions - Find the minimum PFN registered
  *
@@ -7071,7 +7053,7 @@ static unsigned long __init find_min_pfn_for_node(int nid)
  */
 unsigned long __init find_min_pfn_with_active_regions(void)
 {
-	return find_min_pfn_for_node(MAX_NUMNODES);
+	return PHYS_PFN(memblock_start_of_DRAM());
 }
 
 /*
-- 
2.26.1


^ permalink raw reply related

* [PATCH v2 18/20] mm: clean up free_area_init_node() and its helpers
From: Mike Rapoport @ 2020-04-29 12:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
	Heiko Carstens, Michal Hocko, James E.J. Bottomley, Max Filippov,
	Guo Ren, linux-csky, linux-parisc, sparclinux, linux-hexagon,
	linux-riscv, Mike Rapoport, Greg Ungerer, linux-arch, linux-s390,
	linux-c6x-dev, Baoquan He, Jonathan Corbet, linux-sh,
	Helge Deller, x86, Russell King, Ley Foon Tan, Yoshinori Sato,
	Geert Uytterhoeven, linux-arm-kernel, Mark Salter, Matt Turner,
	linux-snps-arc, uclinux-h8-devel, linux-xtensa, linux-alpha,
	linux-um, linux-m68k, Tony Luck, Qian Cai, Greentime Hu,
	Paul Walmsley, Stafford Horne, Guan Xuetao, Hoan Tran,
	Michal Simek, Thomas Bogendoerfer, Brian Cain, Nick Hu, linux-mm,
	Vineet Gupta, linux-mips, openrisc, Richard Weinberger,
	Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200429121126.17989-1-rppt@kernel.org>

From: Mike Rapoport <rppt@linux.ibm.com>

The free_area_init_node() now always uses memblock info and the zone PFN
limits so it does not need the backwards compatibility functions to
calculate the zone spanned and absent pages. The removal of the compat_
versions of zone_{abscent,spanned}_pages_in_node() in turn, makes zone_size
and zhole_size parameters unused.

The node_start_pfn is determined by get_pfn_range_for_nid(), so there is no
need to pass it to free_area_init_node().

As the result, the only required parameter to free_area_init_node() is the
node ID, all the rest are removed along with no longer used
compat_zone_{abscent,spanned}_pages_in_node() helpers.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/x86/mm/numa.c |   2 +-
 include/linux/mm.h |   7 +--
 mm/page_alloc.c    | 110 +++++++++------------------------------------
 3 files changed, 24 insertions(+), 95 deletions(-)

diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
index fe024b2ac796..0e1b99f491e4 100644
--- a/arch/x86/mm/numa.c
+++ b/arch/x86/mm/numa.c
@@ -742,7 +742,7 @@ static void __init init_memory_less_node(int nid)
 
 	/* Allocate and initialize node data. Memory-less node is now online.*/
 	alloc_node_data(nid);
-	free_area_init_node(nid, zones_size, 0, zholes_size);
+	free_area_init_node(nid);
 
 	/*
 	 * All zonelists will be built later in start_kernel() after per cpu
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 1c2ecb42e043..2c0d42b11f3c 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2272,8 +2272,7 @@ static inline spinlock_t *pud_lock(struct mm_struct *mm, pud_t *pud)
 }
 
 extern void __init pagecache_init(void);
-extern void __init free_area_init_node(int nid, unsigned long * zones_size,
-		unsigned long zone_start_pfn, unsigned long *zholes_size);
+extern void __init free_area_init_node(int nid);
 extern void free_initmem(void);
 
 /*
@@ -2346,9 +2345,7 @@ static inline unsigned long get_num_physpages(void)
 /*
  * Using memblock node mappings, an architecture may initialise its
  * zones, allocate the backing mem_map and account for memory holes in a more
- * architecture independent manner. This is a substitute for creating the
- * zone_sizes[] and zholes_size[] arrays and passing them to
- * free_area_init_node()
+ * architecture independent manner.
  *
  * An architecture is expected to register range of page frames backed by
  * physical memory with memblock_add[_node]() before calling
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 98a47f90065a..30d171451d4c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6420,8 +6420,7 @@ static unsigned long __init zone_spanned_pages_in_node(int nid,
 					unsigned long node_start_pfn,
 					unsigned long node_end_pfn,
 					unsigned long *zone_start_pfn,
-					unsigned long *zone_end_pfn,
-					unsigned long *ignored)
+					unsigned long *zone_end_pfn)
 {
 	unsigned long zone_low = arch_zone_lowest_possible_pfn[zone_type];
 	unsigned long zone_high = arch_zone_highest_possible_pfn[zone_type];
@@ -6485,8 +6484,7 @@ unsigned long __init absent_pages_in_range(unsigned long start_pfn,
 static unsigned long __init zone_absent_pages_in_node(int nid,
 					unsigned long zone_type,
 					unsigned long node_start_pfn,
-					unsigned long node_end_pfn,
-					unsigned long *ignored)
+					unsigned long node_end_pfn)
 {
 	unsigned long zone_low = arch_zone_lowest_possible_pfn[zone_type];
 	unsigned long zone_high = arch_zone_highest_possible_pfn[zone_type];
@@ -6533,43 +6531,9 @@ static unsigned long __init zone_absent_pages_in_node(int nid,
 	return nr_absent;
 }
 
-static inline unsigned long __init compat_zone_spanned_pages_in_node(int nid,
-					unsigned long zone_type,
-					unsigned long node_start_pfn,
-					unsigned long node_end_pfn,
-					unsigned long *zone_start_pfn,
-					unsigned long *zone_end_pfn,
-					unsigned long *zones_size)
-{
-	unsigned int zone;
-
-	*zone_start_pfn = node_start_pfn;
-	for (zone = 0; zone < zone_type; zone++)
-		*zone_start_pfn += zones_size[zone];
-
-	*zone_end_pfn = *zone_start_pfn + zones_size[zone_type];
-
-	return zones_size[zone_type];
-}
-
-static inline unsigned long __init compat_zone_absent_pages_in_node(int nid,
-						unsigned long zone_type,
-						unsigned long node_start_pfn,
-						unsigned long node_end_pfn,
-						unsigned long *zholes_size)
-{
-	if (!zholes_size)
-		return 0;
-
-	return zholes_size[zone_type];
-}
-
 static void __init calculate_node_totalpages(struct pglist_data *pgdat,
 						unsigned long node_start_pfn,
-						unsigned long node_end_pfn,
-						unsigned long *zones_size,
-						unsigned long *zholes_size,
-						bool compat)
+						unsigned long node_end_pfn)
 {
 	unsigned long realtotalpages = 0, totalpages = 0;
 	enum zone_type i;
@@ -6580,31 +6544,14 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat,
 		unsigned long spanned, absent;
 		unsigned long size, real_size;
 
-		if (compat) {
-			spanned = compat_zone_spanned_pages_in_node(
-						pgdat->node_id, i,
-						node_start_pfn,
-						node_end_pfn,
-						&zone_start_pfn,
-						&zone_end_pfn,
-						zones_size);
-			absent = compat_zone_absent_pages_in_node(
-						pgdat->node_id, i,
-						node_start_pfn,
-						node_end_pfn,
-						zholes_size);
-		} else {
-			spanned = zone_spanned_pages_in_node(pgdat->node_id, i,
-						node_start_pfn,
-						node_end_pfn,
-						&zone_start_pfn,
-						&zone_end_pfn,
-						zones_size);
-			absent = zone_absent_pages_in_node(pgdat->node_id, i,
-						node_start_pfn,
-						node_end_pfn,
-						zholes_size);
-		}
+		spanned = zone_spanned_pages_in_node(pgdat->node_id, i,
+						     node_start_pfn,
+						     node_end_pfn,
+						     &zone_start_pfn,
+						     &zone_end_pfn);
+		absent = zone_absent_pages_in_node(pgdat->node_id, i,
+						   node_start_pfn,
+						   node_end_pfn);
 
 		size = spanned;
 		real_size = size - absent;
@@ -6926,10 +6873,7 @@ static inline void pgdat_set_deferred_range(pg_data_t *pgdat)
 static inline void pgdat_set_deferred_range(pg_data_t *pgdat) {}
 #endif
 
-static void __init __free_area_init_node(int nid, unsigned long *zones_size,
-					 unsigned long node_start_pfn,
-					 unsigned long *zholes_size,
-					 bool compat)
+void __init free_area_init_node(int nid)
 {
 	pg_data_t *pgdat = NODE_DATA(nid);
 	unsigned long start_pfn = 0;
@@ -6938,19 +6882,16 @@ static void __init __free_area_init_node(int nid, unsigned long *zones_size,
 	/* pg_data_t should be reset to zero when it's allocated */
 	WARN_ON(pgdat->nr_zones || pgdat->kswapd_classzone_idx);
 
+	get_pfn_range_for_nid(nid, &start_pfn, &end_pfn);
+
 	pgdat->node_id = nid;
-	pgdat->node_start_pfn = node_start_pfn;
+	pgdat->node_start_pfn = start_pfn;
 	pgdat->per_cpu_nodestats = NULL;
-	if (!compat) {
-		get_pfn_range_for_nid(nid, &start_pfn, &end_pfn);
-		pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,
-			(u64)start_pfn << PAGE_SHIFT,
-			end_pfn ? ((u64)end_pfn << PAGE_SHIFT) - 1 : 0);
-	} else {
-		start_pfn = node_start_pfn;
-	}
-	calculate_node_totalpages(pgdat, start_pfn, end_pfn,
-				  zones_size, zholes_size, compat);
+
+	pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,
+		(u64)start_pfn << PAGE_SHIFT,
+		end_pfn ? ((u64)end_pfn << PAGE_SHIFT) - 1 : 0);
+	calculate_node_totalpages(pgdat, start_pfn, end_pfn);
 
 	alloc_node_mem_map(pgdat);
 	pgdat_set_deferred_range(pgdat);
@@ -6958,14 +6899,6 @@ static void __init __free_area_init_node(int nid, unsigned long *zones_size,
 	free_area_init_core(pgdat);
 }
 
-void __init free_area_init_node(int nid, unsigned long *zones_size,
-				unsigned long node_start_pfn,
-				unsigned long *zholes_size)
-{
-	__free_area_init_node(nid, zones_size, node_start_pfn, zholes_size,
-			      true);
-}
-
 #if !defined(CONFIG_FLAT_NODE_MEM_MAP)
 /*
  * Initialize all valid struct pages in the range [spfn, epfn) and mark them
@@ -7491,8 +7424,7 @@ void __init free_area_init(unsigned long *max_zone_pfn)
 	init_unavailable_mem();
 	for_each_online_node(nid) {
 		pg_data_t *pgdat = NODE_DATA(nid);
-		__free_area_init_node(nid, NULL,
-				      find_min_pfn_for_node(nid), NULL, false);
+		free_area_init_node(nid);
 
 		/* Any memory on that node */
 		if (pgdat->node_present_pages)
-- 
2.26.1


^ permalink raw reply related

* [PATCH v2 17/20] mm: free_area_init: allow defining max_zone_pfn in descending order
From: Mike Rapoport @ 2020-04-29 12:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
	Heiko Carstens, Michal Hocko, James E.J. Bottomley, Max Filippov,
	Guo Ren, linux-csky, linux-parisc, sparclinux, linux-hexagon,
	linux-riscv, Mike Rapoport, Greg Ungerer, linux-arch, linux-s390,
	linux-c6x-dev, Baoquan He, Jonathan Corbet, linux-sh,
	Helge Deller, x86, Russell King, Ley Foon Tan, Yoshinori Sato,
	Geert Uytterhoeven, linux-arm-kernel, Mark Salter, Matt Turner,
	linux-snps-arc, uclinux-h8-devel, linux-xtensa, linux-alpha,
	linux-um, linux-m68k, Tony Luck, Qian Cai, Greentime Hu,
	Paul Walmsley, Stafford Horne, Guan Xuetao, Hoan Tran,
	Michal Simek, Thomas Bogendoerfer, Brian Cain, Nick Hu, linux-mm,
	Vineet Gupta, linux-mips, openrisc, Richard Weinberger,
	Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200429121126.17989-1-rppt@kernel.org>

From: Mike Rapoport <rppt@linux.ibm.com>

Some architectures (e.g. ARC) have the ZONE_HIGHMEM zone below the
ZONE_NORMAL. Allowing free_area_init() parse max_zone_pfn array even it is
sorted in descending order allows using free_area_init() on such
architectures.

Add top -> down traversal of max_zone_pfn array in free_area_init() and use
the latter in ARC node/zone initialization.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/arc/mm/init.c | 36 +++++++-----------------------------
 mm/page_alloc.c    | 24 +++++++++++++++++++-----
 2 files changed, 26 insertions(+), 34 deletions(-)

diff --git a/arch/arc/mm/init.c b/arch/arc/mm/init.c
index 0920c969c466..41eb9be1653c 100644
--- a/arch/arc/mm/init.c
+++ b/arch/arc/mm/init.c
@@ -63,11 +63,13 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
 
 		low_mem_sz = size;
 		in_use = 1;
+		memblock_add_node(base, size, 0);
 	} else {
 #ifdef CONFIG_HIGHMEM
 		high_mem_start = base;
 		high_mem_sz = size;
 		in_use = 1;
+		memblock_add_node(base, size, 1);
 #endif
 	}
 
@@ -83,8 +85,7 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
  */
 void __init setup_arch_memory(void)
 {
-	unsigned long zones_size[MAX_NR_ZONES];
-	unsigned long zones_holes[MAX_NR_ZONES];
+	unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };
 
 	init_mm.start_code = (unsigned long)_text;
 	init_mm.end_code = (unsigned long)_etext;
@@ -115,7 +116,6 @@ void __init setup_arch_memory(void)
 	 * the crash
 	 */
 
-	memblock_add_node(low_mem_start, low_mem_sz, 0);
 	memblock_reserve(CONFIG_LINUX_LINK_BASE,
 			 __pa(_end) - CONFIG_LINUX_LINK_BASE);
 
@@ -133,22 +133,7 @@ void __init setup_arch_memory(void)
 	memblock_dump_all();
 
 	/*----------------- node/zones setup --------------------------*/
-	memset(zones_size, 0, sizeof(zones_size));
-	memset(zones_holes, 0, sizeof(zones_holes));
-
-	zones_size[ZONE_NORMAL] = max_low_pfn - min_low_pfn;
-	zones_holes[ZONE_NORMAL] = 0;
-
-	/*
-	 * We can't use the helper free_area_init(zones[]) because it uses
-	 * PAGE_OFFSET to compute the @min_low_pfn which would be wrong
-	 * when our kernel doesn't start at PAGE_OFFSET, i.e.
-	 * PAGE_OFFSET != CONFIG_LINUX_RAM_BASE
-	 */
-	free_area_init_node(0,			/* node-id */
-			    zones_size,		/* num pages per zone */
-			    min_low_pfn,	/* first pfn of node */
-			    zones_holes);	/* holes */
+	max_zone_pfn[ZONE_NORMAL] = max_low_pfn;
 
 #ifdef CONFIG_HIGHMEM
 	/*
@@ -168,20 +153,13 @@ void __init setup_arch_memory(void)
 	min_high_pfn = PFN_DOWN(high_mem_start);
 	max_high_pfn = PFN_DOWN(high_mem_start + high_mem_sz);
 
-	zones_size[ZONE_NORMAL] = 0;
-	zones_holes[ZONE_NORMAL] = 0;
-
-	zones_size[ZONE_HIGHMEM] = max_high_pfn - min_high_pfn;
-	zones_holes[ZONE_HIGHMEM] = 0;
-
-	free_area_init_node(1,			/* node-id */
-			    zones_size,		/* num pages per zone */
-			    min_high_pfn,	/* first pfn of node */
-			    zones_holes);	/* holes */
+	max_zone_pfn[ZONE_HIGHMEM] = max_high_pfn;
 
 	high_memory = (void *)(min_high_pfn << PAGE_SHIFT);
 	kmap_init();
 #endif
+
+	free_area_init(max_zone_pfn);
 }
 
 /*
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index d35ca0996a09..98a47f90065a 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7408,7 +7408,8 @@ static void check_for_memory(pg_data_t *pgdat, int nid)
 void __init free_area_init(unsigned long *max_zone_pfn)
 {
 	unsigned long start_pfn, end_pfn;
-	int i, nid;
+	int i, nid, zone;
+	bool descending = false;
 
 	/* Record where the zone boundaries are */
 	memset(arch_zone_lowest_possible_pfn, 0,
@@ -7418,13 +7419,26 @@ void __init free_area_init(unsigned long *max_zone_pfn)
 
 	start_pfn = find_min_pfn_with_active_regions();
 
+	/*
+	 * Some architecturs, e.g. ARC may have ZONE_HIGHMEM below
+	 * ZONE_NORMAL. For such cases we allow max_zone_pfn sorted in the
+	 * descending order
+	 */
+	if (MAX_NR_ZONES > 1 && max_zone_pfn[0] > max_zone_pfn[1])
+		descending = true;
+
 	for (i = 0; i < MAX_NR_ZONES; i++) {
-		if (i == ZONE_MOVABLE)
+		if (descending)
+			zone = MAX_NR_ZONES - i - 1;
+		else
+			zone = i;
+
+		if (zone == ZONE_MOVABLE)
 			continue;
 
-		end_pfn = max(max_zone_pfn[i], start_pfn);
-		arch_zone_lowest_possible_pfn[i] = start_pfn;
-		arch_zone_highest_possible_pfn[i] = end_pfn;
+		end_pfn = max(max_zone_pfn[zone], start_pfn);
+		arch_zone_lowest_possible_pfn[zone] = start_pfn;
+		arch_zone_highest_possible_pfn[zone] = end_pfn;
 
 		start_pfn = end_pfn;
 	}
-- 
2.26.1


^ permalink raw reply related

* Re: New powerpc vdso calling convention
From: Adhemerval Zanella @ 2020-04-29 12:15 UTC (permalink / raw)
  To: Nicholas Piggin, Rich Felker
  Cc: libc-alpha, musl, binutils, Andy Lutomirski, libc-dev,
	Thomas Gleixner, Vincenzo Frascino, linuxppc-dev
In-Reply-To: <1588126678.zjwj4d1d90.astroid@bobo.none>



On 28/04/2020 23:39, Nicholas Piggin wrote:
> Excerpts from Adhemerval Zanella's message of April 27, 2020 11:09 pm:
>>
>>
>> On 26/04/2020 00:41, Nicholas Piggin wrote:
>>> Excerpts from Rich Felker's message of April 26, 2020 9:11 am:
>>>> On Sun, Apr 26, 2020 at 08:58:19AM +1000, Nicholas Piggin wrote:
>>>>> Excerpts from Christophe Leroy's message of April 25, 2020 10:20 pm:
>>>>>>
>>>>>>
>>>>>> Le 25/04/2020 à 12:56, Nicholas Piggin a écrit :
>>>>>>> Excerpts from Christophe Leroy's message of April 25, 2020 5:47 pm:
>>>>>>>>
>>>>>>>>
>>>>>>>> Le 25/04/2020 à 07:22, Nicholas Piggin a écrit :
>>>>>>>>> As noted in the 'scv' thread, powerpc's vdso calling convention does not
>>>>>>>>> match the C ELF ABI calling convention (or the proposed scv convention).
>>>>>>>>> I think we could implement a new ABI by basically duplicating function
>>>>>>>>> entry points with different names.
>>>>>>>>
>>>>>>>> I think doing this is a real good idea.
>>>>>>>>
>>>>>>>> I've been working at porting powerpc VDSO to the GENERIC C VDSO, and the
>>>>>>>> main pitfall has been that our vdso calling convention is not compatible
>>>>>>>> with C calling convention, so we have go through an ASM entry/exit.
>>>>>>>>
>>>>>>>> See https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=171469
>>>>>>>>
>>>>>>>> We should kill this error flag return through CR[SO] and get it the
>>>>>>>> "modern" way like other architectectures implementing the C VDSO: return
>>>>>>>> 0 when successfull, return -err when failed.
>>>>>>>
>>>>>>> Agreed.
>>>>>>>
>>>>>>>>> The ELF v2 ABI convention would suit it well, because the caller already
>>>>>>>>> requires the function address for ctr, so having it in r12 will
>>>>>>>>> eliminate the need for address calculation, which suits the vdso data
>>>>>>>>> page access.
>>>>>>>>>
>>>>>>>>> Is there a need for ELF v1 specific calls as well, or could those just be
>>>>>>>>> deprecated and remain on existing functions or required to use the ELF
>>>>>>>>> v2 calls using asm wrappers?
>>>>>>>>
>>>>>>>> What's ELF v1 and ELF v2 ? Is ELF v1 what PPC32 uses ? If so, I'd say
>>>>>>>> yes, it would be good to have it to avoid going through ASM in the middle.
>>>>>>>
>>>>>>> I'm not sure about PPC32. On PPC64, ELFv2 functions must be called with
>>>>>>> their address in r12 if called at their global entry point. ELFv1 have a
>>>>>>> function descriptor with call address and TOC in it, caller has to load
>>>>>>> the TOC if it's global.
>>>>>>>
>>>>>>> The vdso doesn't have TOC, it has one global address (the vdso data
>>>>>>> page) which it loads by calculating its own address.
>>>>>>>
>>>>>>> The kernel doesn't change the vdso based on whether it's called by a v1
>>>>>>> or v2 userspace (it doesn't really know itself and would have to export
>>>>>>> different functions). glibc has a hack to create something:
>>>>>>>
>>>>>>> # define VDSO_IFUNC_RET(value)                           \
>>>>>>>    ({                                                     \
>>>>>>>      static Elf64_FuncDesc vdso_opd = { .fd_toc = ~0x0 }; \
>>>>>>>      vdso_opd.fd_func = (Elf64_Addr)value;                \
>>>>>>>      &vdso_opd;                                           \
>>>>>>>    })
>>>>>>>
>>>>>>> If we could make something which links more like any other dso with
>>>>>>> ELFv1, that would be good. Otherwise I think v2 is preferable so it
>>>>>>> doesn't have to calculate its own address.
>>>>>>
>>>>>> I see the following in glibc. So looks like PPC32 is like PPC64 elfv1. 
>>>>>> By the way, they are talking about something not completely finished in 
>>>>>> the kernel. Can we finish it ?
>>>>>
>>>>> Possibly can. It seems like a good idea to fix all loose ends if we are 
>>>>> going to add new versions. Will have to check with the toolchain people 
>>>>> to make sure we're doing the right thing.
>>>>
>>>> "ELFv1" and "ELFv2" are PPC64-specific names for the old and new
>>>> version of the ELF psABI for PPC64. They have nothing at all to do
>>>> with PPC32 which is a completely different ABI from either.
>>>
>>> Right, I'm just talking about those comments -- it seems like the kernel 
>>> vdso should contain an .opd section with function descriptors in it for
>>> elfv1 calls, rather than the hack it has now of creating one in the 
>>> caller's .data section.
>>>
>>> But all that function descriptor code is gated by
>>>
>>> #if (defined(__PPC64__) || defined(__powerpc64__)) && _CALL_ELF != 2
>>>
>>> So it seems PPC32 does not use function descriptors but a direct pointer 
>>> to the entry point like PPC64 with ELFv2.
>>
>> Yes, this hack is only for ELFv1.  The missing ODP has not been an issue 
>> or glibc because it has been using the inline assembly to emulate the 
>> functions call since initial vDSO support (INTERNAL_VSYSCALL_CALL_TYPE).
>> It just has become an issue when I added a ifunc optimization to 
>> gettimeofday so it can bypass the libc.so and make plt branch to vDSO 
>> directly.
> 
> I can't understand if it's actually a problem for you or not.
> 
> Regardless if you can hack around it, it seems to me that if we're going 
> to add sane calling conventions to the vdso, then we should also just 
> have a .opd section for it as well, whether or not a particular libc 
> requires it.

The main problem for glibc is the complication of having to handle two
different calling conventions.  Specially if kernel starts to provide 
new vDSO symbols with only with the new semantic. 

But I think it is doable, it will require some internal tinkering on
how to handle vDSO (to indicate which mechanism to use) which will 
most likely be powerpc specific.

> 
>> Recently on some y2038 refactoring it was suggested to get rid of this 
>> and make gettimeofday call clock_gettime regardless.  But some felt that 
>> the performance degradation was not worth for a symbol that is still used
>> extensibility, so we stuck with the hack.
>>
>> And I think having this synthetic opd entry is not an issue, since for 
>> full relro the program's will be used and correctly set as read-only.
> 
> I'm not quite sure what this means, I don't really know how glibc ifunc 
> works. How do you set r2 if you have no opd?

IFUNC itself is not an issue here, since it just a dynamic relocation that
instruct the dynamic linker to issue a defined function that provides the
actual symbol. The problem is symbol resolution for kernel vDSO symbol
that returns a pointer to the text segment instead of the expected ODP 
entry.

And currently glibc assumes that kernel vDSO does not use TOC or AUX,
so it sets a bogus value (~0x0) just to avoid trigger lazy resolution
in some cases. It makes sense with the current contract that vDSO calls
should behave as syscall, but lesser the flexibility of kernel 
implementation.

> 
>> The issue is more for glibc itself, and I wouldn't mind to just remove the
>> gettimeofday and time optimizations and use the default vDSO support
>> (which might increase in function latency though).
>>
>> As Rich has put, it would be simpler to just have powerpc vDSO symbols
>> to have a default function call semantic so we could issue a function
>> call directly.  But for powerpc64, we glibc will need to continue to 
>> support this non-standard call on older kernels and I am not sure if
>> adding new symbols with a different semantic will help much.
> 
> Yeah, we will add entry points with default function call semantics.
> At which point we make the things look like any other dso unless there 
> is good reason otherwise.

I think the move to make vDSO has the same semantic as an usual DSO is
the correct one.  I am just pointing out that different than musl, glibc
already support vDSO for powerpc and changing its interface will most
likely require more handling in powerpc specific bits.

> 
>> GLibc already hides this powerpc semantic on INTERNAL_VSYSCALL_CALL_TYPE,
>> so internally all syscalls are assumed to have the new semantic (-errno
>> on error, 0 on success). Adding another ELFv1 would require to add
>> more logic to handle multiple symbol version for vDSO setup
>> (sysdeps/unix/sysv/linux/dl-vdso-setup.h), which would mostly likely to
>> require an arch-specific implementation to handle it.
> 
> Is it not a build-time choice? The arch can set its own vdso symbol 
> names AFAIKS.

To enable vDSO support the architecture just need to define the
correspondent macros with the expected names. For instance, for powerpc:

sysdeps/unix/sysv/linux/powerpc/sysdep.h
[...]
195 #if defined(__PPC64__) || defined(__powerpc64__)
196 #define HAVE_CLOCK_GETRES64_VSYSCALL    "__kernel_clock_getres"
197 #define HAVE_CLOCK_GETTIME64_VSYSCALL   "__kernel_clock_gettime"
198 #else
199 #define HAVE_CLOCK_GETRES_VSYSCALL      "__kernel_clock_getres"
200 #define HAVE_CLOCK_GETTIME_VSYSCALL     "__kernel_clock_gettime"
201 #endif
202 #define HAVE_GETCPU_VSYSCALL            "__kernel_getcpu"
203 #define HAVE_TIME_VSYSCALL              "__kernel_time"
204 #define HAVE_GETTIMEOFDAY_VSYSCALL      "__kernel_gettimeofday"
205 #define HAVE_GET_TBFREQ                 "__kernel_get_tbfreq"
[...]

GLIBC will create and initialize the vDSO pointers in a arch neutral 
way, however the vDSO call itself is parametrized to handle the 
powerpc specific bits (the INTERNAL_VSYSCALL_CALL_TYPE which is called
by INLINE_SYSCALL_CALL).

> 
> Thanks,
> Nick
> 

^ permalink raw reply

* [PATCH v2 16/20] mm: remove early_pfn_in_nid() and CONFIG_NODES_SPAN_OTHER_NODES
From: Mike Rapoport @ 2020-04-29 12:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
	Heiko Carstens, Michal Hocko, James E.J. Bottomley, Max Filippov,
	Guo Ren, linux-csky, linux-parisc, sparclinux, linux-hexagon,
	linux-riscv, Mike Rapoport, Greg Ungerer, linux-arch, linux-s390,
	linux-c6x-dev, Baoquan He, Jonathan Corbet, linux-sh,
	Helge Deller, x86, Russell King, Ley Foon Tan, Yoshinori Sato,
	Geert Uytterhoeven, linux-arm-kernel, Mark Salter, Matt Turner,
	linux-snps-arc, uclinux-h8-devel, linux-xtensa, linux-alpha,
	linux-um, linux-m68k, Tony Luck, Qian Cai, Greentime Hu,
	Paul Walmsley, Stafford Horne, Guan Xuetao, Hoan Tran,
	Michal Simek, Thomas Bogendoerfer, Brian Cain, Nick Hu, linux-mm,
	Vineet Gupta, linux-mips, openrisc, Richard Weinberger,
	Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200429121126.17989-1-rppt@kernel.org>

From: Mike Rapoport <rppt@linux.ibm.com>

The commit f47ac088c406 ("mm: memmap_init: iterate over memblock regions
rather that check each PFN") made early_pfn_in_nid() obsolete and since
CONFIG_NODES_SPAN_OTHER_NODES is only used to pick a stub or a real
implementation of early_pfn_in_nid() it is also not needed anymore.

Remove both early_pfn_in_nid() and the CONFIG_NODES_SPAN_OTHER_NODES.

Co-developed-by: Hoan Tran <Hoan@os.amperecomputing.com>
Signed-off-by: Hoan Tran <Hoan@os.amperecomputing.com>
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/powerpc/Kconfig |  9 ---------
 arch/sparc/Kconfig   |  9 ---------
 arch/x86/Kconfig     |  9 ---------
 mm/page_alloc.c      | 20 --------------------
 4 files changed, 47 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 5f86b22b7d2c..74f316deeae1 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -685,15 +685,6 @@ config ARCH_MEMORY_PROBE
 	def_bool y
 	depends on MEMORY_HOTPLUG
 
-# Some NUMA nodes have memory ranges that span
-# other nodes.  Even though a pfn is valid and
-# between a node's start and end pfns, it may not
-# reside on that node.  See memmap_init_zone()
-# for details.
-config NODES_SPAN_OTHER_NODES
-	def_bool y
-	depends on NEED_MULTIPLE_NODES
-
 config STDBINUTILS
 	bool "Using standard binutils settings"
 	depends on 44x
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 795206b7b552..0e4f3891b904 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -286,15 +286,6 @@ config NODES_SHIFT
 	  Specify the maximum number of NUMA Nodes available on the target
 	  system.  Increases memory reserved to accommodate various tables.
 
-# Some NUMA nodes have memory ranges that span
-# other nodes.  Even though a pfn is valid and
-# between a node's start and end pfns, it may not
-# reside on that node.  See memmap_init_zone()
-# for details.
-config NODES_SPAN_OTHER_NODES
-	def_bool y
-	depends on NEED_MULTIPLE_NODES
-
 config ARCH_SPARSEMEM_ENABLE
 	def_bool y if SPARC64
 	select SPARSEMEM_VMEMMAP_ENABLE
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f8bf218a169c..1ec2a5e2fef6 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1581,15 +1581,6 @@ config X86_64_ACPI_NUMA
 	---help---
 	  Enable ACPI SRAT based node topology detection.
 
-# Some NUMA nodes have memory ranges that span
-# other nodes.  Even though a pfn is valid and
-# between a node's start and end pfns, it may not
-# reside on that node.  See memmap_init_zone()
-# for details.
-config NODES_SPAN_OTHER_NODES
-	def_bool y
-	depends on X86_64_ACPI_NUMA
-
 config NUMA_EMU
 	bool "NUMA emulation"
 	depends on NUMA
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 8d112defaead..d35ca0996a09 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1541,26 +1541,6 @@ int __meminit early_pfn_to_nid(unsigned long pfn)
 }
 #endif /* CONFIG_NEED_MULTIPLE_NODES */
 
-#ifdef CONFIG_NODES_SPAN_OTHER_NODES
-/* Only safe to use early in boot when initialisation is single-threaded */
-static inline bool __meminit early_pfn_in_nid(unsigned long pfn, int node)
-{
-	int nid;
-
-	nid = __early_pfn_to_nid(pfn, &early_pfnnid_cache);
-	if (nid >= 0 && nid != node)
-		return false;
-	return true;
-}
-
-#else
-static inline bool __meminit early_pfn_in_nid(unsigned long pfn, int node)
-{
-	return true;
-}
-#endif
-
-
 void __init memblock_free_pages(struct page *page, unsigned long pfn,
 							unsigned int order)
 {
-- 
2.26.1


^ permalink raw reply related

* [PATCH v2 15/20] mm: memmap_init: iterate over memblock regions rather that check each PFN
From: Mike Rapoport @ 2020-04-29 12:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
	Heiko Carstens, Michal Hocko, James E.J. Bottomley, Max Filippov,
	Guo Ren, linux-csky, linux-parisc, sparclinux, linux-hexagon,
	linux-riscv, Mike Rapoport, Greg Ungerer, linux-arch, linux-s390,
	linux-c6x-dev, Baoquan He, Jonathan Corbet, linux-sh,
	Helge Deller, x86, Russell King, Ley Foon Tan, Yoshinori Sato,
	Geert Uytterhoeven, linux-arm-kernel, Mark Salter, Matt Turner,
	linux-snps-arc, uclinux-h8-devel, linux-xtensa, linux-alpha,
	linux-um, linux-m68k, Tony Luck, Qian Cai, Greentime Hu,
	Paul Walmsley, Stafford Horne, Guan Xuetao, Hoan Tran,
	Michal Simek, Thomas Bogendoerfer, Brian Cain, Nick Hu, linux-mm,
	Vineet Gupta, linux-mips, openrisc, Richard Weinberger,
	Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200429121126.17989-1-rppt@kernel.org>

From: Baoquan He <bhe@redhat.com>

When called during boot the memmap_init_zone() function checks if each PFN
is valid and actually belongs to the node being initialized using
early_pfn_valid() and early_pfn_in_nid().

Each such check may cost up to O(log(n)) where n is the number of memory
banks, so for large amount of memory overall time spent in early_pfn*()
becomes substantial.

Since the information is anyway present in memblock, we can iterate over
memblock memory regions in memmap_init() and only call memmap_init_zone()
for PFN ranges that are know to be valid and in the appropriate node.

Signed-off-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 mm/page_alloc.c | 47 ++++++++++++++++-------------------------------
 1 file changed, 16 insertions(+), 31 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 7f6a3081edb8..8d112defaead 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5939,23 +5939,6 @@ overlap_memmap_init(unsigned long zone, unsigned long *pfn)
 	return false;
 }
 
-#ifdef CONFIG_SPARSEMEM
-/* Skip PFNs that belong to non-present sections */
-static inline __meminit unsigned long next_pfn(unsigned long pfn)
-{
-	const unsigned long section_nr = pfn_to_section_nr(++pfn);
-
-	if (present_section_nr(section_nr))
-		return pfn;
-	return section_nr_to_pfn(next_present_section_nr(section_nr));
-}
-#else
-static inline __meminit unsigned long next_pfn(unsigned long pfn)
-{
-	return pfn++;
-}
-#endif
-
 /*
  * Initially all pages are reserved - free ones are freed
  * up by memblock_free_all() once the early boot process is
@@ -5990,19 +5973,7 @@ void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
 #endif
 
 	for (pfn = start_pfn; pfn < end_pfn; ) {
-		/*
-		 * There can be holes in boot-time mem_map[]s handed to this
-		 * function.  They do not exist on hotplugged memory.
-		 */
 		if (context == MEMMAP_EARLY) {
-			if (!early_pfn_valid(pfn)) {
-				pfn = next_pfn(pfn);
-				continue;
-			}
-			if (!early_pfn_in_nid(pfn, nid)) {
-				pfn++;
-				continue;
-			}
 			if (overlap_memmap_init(zone, &pfn))
 				continue;
 			if (defer_init(nid, pfn, end_pfn))
@@ -6118,9 +6089,23 @@ static void __meminit zone_init_free_lists(struct zone *zone)
 }
 
 void __meminit __weak memmap_init(unsigned long size, int nid,
-				  unsigned long zone, unsigned long start_pfn)
+				  unsigned long zone,
+				  unsigned long range_start_pfn)
 {
-	memmap_init_zone(size, nid, zone, start_pfn, MEMMAP_EARLY, NULL);
+	unsigned long start_pfn, end_pfn;
+	unsigned long range_end_pfn = range_start_pfn + size;
+	int i;
+
+	for_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) {
+		start_pfn = clamp(start_pfn, range_start_pfn, range_end_pfn);
+		end_pfn = clamp(end_pfn, range_start_pfn, range_end_pfn);
+
+		if (end_pfn > start_pfn) {
+			size = end_pfn - start_pfn;
+			memmap_init_zone(size, nid, zone, start_pfn,
+					 MEMMAP_EARLY, NULL);
+		}
+	}
 }
 
 static int zone_batchsize(struct zone *zone)
-- 
2.26.1


^ permalink raw reply related

* [PATCH v2 14/20] xtensa: simplify detection of memory zone boundaries
From: Mike Rapoport @ 2020-04-29 12:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
	Heiko Carstens, Michal Hocko, James E.J. Bottomley, Max Filippov,
	Guo Ren, linux-csky, linux-parisc, sparclinux, linux-hexagon,
	linux-riscv, Mike Rapoport, Greg Ungerer, linux-arch, linux-s390,
	linux-c6x-dev, Baoquan He, Jonathan Corbet, linux-sh,
	Helge Deller, x86, Russell King, Ley Foon Tan, Yoshinori Sato,
	Geert Uytterhoeven, linux-arm-kernel, Mark Salter, Matt Turner,
	linux-snps-arc, uclinux-h8-devel, linux-xtensa, linux-alpha,
	linux-um, linux-m68k, Tony Luck, Qian Cai, Greentime Hu,
	Paul Walmsley, Stafford Horne, Guan Xuetao, Hoan Tran,
	Michal Simek, Thomas Bogendoerfer, Brian Cain, Nick Hu, linux-mm,
	Vineet Gupta, linux-mips, openrisc, Richard Weinberger,
	Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200429121126.17989-1-rppt@kernel.org>

From: Mike Rapoport <rppt@linux.ibm.com>

The free_area_init() function only requires the definition of maximal PFN
for each of the supported zone rater than calculation of actual zone sizes
and the sizes of the holes between the zones.

After removal of CONFIG_HAVE_MEMBLOCK_NODE_MAP the free_area_init() is
available to all architectures.

Using this function instead of free_area_init_node() simplifies the zone
detection.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/xtensa/mm/init.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c
index 19c625e6d81f..a05b306cf371 100644
--- a/arch/xtensa/mm/init.c
+++ b/arch/xtensa/mm/init.c
@@ -70,13 +70,13 @@ void __init bootmem_init(void)
 void __init zones_init(void)
 {
 	/* All pages are DMA-able, so we put them all in the DMA zone. */
-	unsigned long zones_size[MAX_NR_ZONES] = {
-		[ZONE_NORMAL] = max_low_pfn - ARCH_PFN_OFFSET,
+	unsigned long max_zone_pfn[MAX_NR_ZONES] = {
+		[ZONE_NORMAL] = max_low_pfn,
 #ifdef CONFIG_HIGHMEM
-		[ZONE_HIGHMEM] = max_pfn - max_low_pfn,
+		[ZONE_HIGHMEM] = max_pfn,
 #endif
 	};
-	free_area_init_node(0, zones_size, ARCH_PFN_OFFSET, NULL);
+	free_area_init(max_zone_pfn);
 }
 
 #ifdef CONFIG_HIGHMEM
-- 
2.26.1


^ permalink raw reply related

* [PATCH v2 13/20] unicore32: simplify detection of memory zone boundaries
From: Mike Rapoport @ 2020-04-29 12:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
	Heiko Carstens, Michal Hocko, James E.J. Bottomley, Max Filippov,
	Guo Ren, linux-csky, linux-parisc, sparclinux, linux-hexagon,
	linux-riscv, Mike Rapoport, Greg Ungerer, linux-arch, linux-s390,
	linux-c6x-dev, Baoquan He, Jonathan Corbet, linux-sh,
	Helge Deller, x86, Russell King, Ley Foon Tan, Yoshinori Sato,
	Geert Uytterhoeven, linux-arm-kernel, Mark Salter, Matt Turner,
	linux-snps-arc, uclinux-h8-devel, linux-xtensa, linux-alpha,
	linux-um, linux-m68k, Tony Luck, Qian Cai, Greentime Hu,
	Paul Walmsley, Stafford Horne, Guan Xuetao, Hoan Tran,
	Michal Simek, Thomas Bogendoerfer, Brian Cain, Nick Hu, linux-mm,
	Vineet Gupta, linux-mips, openrisc, Richard Weinberger,
	Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200429121126.17989-1-rppt@kernel.org>

From: Mike Rapoport <rppt@linux.ibm.com>

The free_area_init() function only requires the definition of maximal PFN
for each of the supported zone rater than calculation of actual zone sizes
and the sizes of the holes between the zones.

After removal of CONFIG_HAVE_MEMBLOCK_NODE_MAP the free_area_init() is
available to all architectures.

Using this function instead of free_area_init_node() simplifies the zone
detection.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/unicore32/include/asm/memory.h  |  2 +-
 arch/unicore32/include/mach/memory.h |  6 ++--
 arch/unicore32/kernel/pci.c          | 14 ++-------
 arch/unicore32/mm/init.c             | 43 ++++++----------------------
 4 files changed, 15 insertions(+), 50 deletions(-)

diff --git a/arch/unicore32/include/asm/memory.h b/arch/unicore32/include/asm/memory.h
index 23c93105f98f..66285178dd9b 100644
--- a/arch/unicore32/include/asm/memory.h
+++ b/arch/unicore32/include/asm/memory.h
@@ -60,7 +60,7 @@
 #ifndef __ASSEMBLY__
 
 #ifndef arch_adjust_zones
-#define arch_adjust_zones(size, holes) do { } while (0)
+#define arch_adjust_zones(max_zone_pfn) do { } while (0)
 #endif
 
 /*
diff --git a/arch/unicore32/include/mach/memory.h b/arch/unicore32/include/mach/memory.h
index 2b527cedd03d..b4e6035cb9a3 100644
--- a/arch/unicore32/include/mach/memory.h
+++ b/arch/unicore32/include/mach/memory.h
@@ -25,10 +25,10 @@
 
 #if !defined(__ASSEMBLY__) && defined(CONFIG_PCI)
 
-void puv3_pci_adjust_zones(unsigned long *size, unsigned long *holes);
+void puv3_pci_adjust_zones(unsigned long *max_zone_pfn);
 
-#define arch_adjust_zones(size, holes) \
-	puv3_pci_adjust_zones(size, holes)
+#define arch_adjust_zones(max_zone_pfn) \
+	puv3_pci_adjust_zones(max_zone_pfn)
 
 #endif
 
diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c
index efa04a94dcdb..0d098aa05b47 100644
--- a/arch/unicore32/kernel/pci.c
+++ b/arch/unicore32/kernel/pci.c
@@ -133,21 +133,11 @@ static int pci_puv3_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  * This is really ugly and we need a better way of specifying
  * DMA-capable regions of memory.
  */
-void __init puv3_pci_adjust_zones(unsigned long *zone_size,
-	unsigned long *zhole_size)
+void __init puv3_pci_adjust_zones(unsigned long max_zone_pfn)
 {
 	unsigned int sz = SZ_128M >> PAGE_SHIFT;
 
-	/*
-	 * Only adjust if > 128M on current system
-	 */
-	if (zone_size[0] <= sz)
-		return;
-
-	zone_size[1] = zone_size[0] - sz;
-	zone_size[0] = sz;
-	zhole_size[1] = zhole_size[0];
-	zhole_size[0] = 0;
+	max_zone_pfn[ZONE_DMA] = sz;
 }
 
 /*
diff --git a/arch/unicore32/mm/init.c b/arch/unicore32/mm/init.c
index 6cf010fadc7a..52425d383cea 100644
--- a/arch/unicore32/mm/init.c
+++ b/arch/unicore32/mm/init.c
@@ -61,46 +61,21 @@ static void __init find_limits(unsigned long *min, unsigned long *max_low,
 	}
 }
 
-static void __init uc32_bootmem_free(unsigned long min, unsigned long max_low,
-	unsigned long max_high)
+static void __init uc32_bootmem_free(unsigned long max_low)
 {
-	unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES];
-	struct memblock_region *reg;
+	unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };
 
-	/*
-	 * initialise the zones.
-	 */
-	memset(zone_size, 0, sizeof(zone_size));
-
-	/*
-	 * The memory size has already been determined.  If we need
-	 * to do anything fancy with the allocation of this memory
-	 * to the zones, now is the time to do it.
-	 */
-	zone_size[0] = max_low - min;
-
-	/*
-	 * Calculate the size of the holes.
-	 *  holes = node_size - sum(bank_sizes)
-	 */
-	memcpy(zhole_size, zone_size, sizeof(zhole_size));
-	for_each_memblock(memory, reg) {
-		unsigned long start = memblock_region_memory_base_pfn(reg);
-		unsigned long end = memblock_region_memory_end_pfn(reg);
-
-		if (start < max_low) {
-			unsigned long low_end = min(end, max_low);
-			zhole_size[0] -= low_end - start;
-		}
-	}
+	max_zone_pfn[ZONE_DMA] = max_low;
+	max_zone_pfn[ZONE_NORMAL] = max_low;
 
 	/*
 	 * Adjust the sizes according to any special requirements for
 	 * this machine type.
+	 * This might lower ZONE_DMA limit.
 	 */
-	arch_adjust_zones(zone_size, zhole_size);
+	arch_adjust_zones(max_zone_pfn);
 
-	free_area_init_node(0, zone_size, min, zhole_size);
+	free_area_init(max_zone_pfn);
 }
 
 int pfn_valid(unsigned long pfn)
@@ -176,11 +151,11 @@ void __init bootmem_init(void)
 	sparse_init();
 
 	/*
-	 * Now free the memory - free_area_init_node needs
+	 * Now free the memory - free_area_init needs
 	 * the sparse mem_map arrays initialized by sparse_init()
 	 * for memmap_init_zone(), otherwise all PFNs are invalid.
 	 */
-	uc32_bootmem_free(min, max_low, max_high);
+	uc32_bootmem_free(max_low);
 
 	high_memory = __va((max_low << PAGE_SHIFT) - 1) + 1;
 
-- 
2.26.1


^ permalink raw reply related

* [PATCH v2 12/20] sparc32: simplify detection of memory zone boundaries
From: Mike Rapoport @ 2020-04-29 12:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
	Heiko Carstens, Michal Hocko, James E.J. Bottomley, Max Filippov,
	Guo Ren, linux-csky, linux-parisc, sparclinux, linux-hexagon,
	linux-riscv, Mike Rapoport, Greg Ungerer, linux-arch, linux-s390,
	linux-c6x-dev, Baoquan He, Jonathan Corbet, linux-sh,
	Helge Deller, x86, Russell King, Ley Foon Tan, Yoshinori Sato,
	Geert Uytterhoeven, linux-arm-kernel, Mark Salter, Matt Turner,
	linux-snps-arc, uclinux-h8-devel, linux-xtensa, linux-alpha,
	linux-um, linux-m68k, Tony Luck, Qian Cai, Greentime Hu,
	Paul Walmsley, Stafford Horne, Guan Xuetao, Hoan Tran,
	Michal Simek, Thomas Bogendoerfer, Brian Cain, Nick Hu, linux-mm,
	Vineet Gupta, linux-mips, openrisc, Richard Weinberger,
	Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200429121126.17989-1-rppt@kernel.org>

From: Mike Rapoport <rppt@linux.ibm.com>

The free_area_init() function only requires the definition of maximal PFN
for each of the supported zone rater than calculation of actual zone sizes
and the sizes of the holes between the zones.

After removal of CONFIG_HAVE_MEMBLOCK_NODE_MAP the free_area_init() is
available to all architectures.

Using this function instead of free_area_init_node() simplifies the zone
detection.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/sparc/mm/srmmu.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)

diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index b7c94de70cca..cc071dd7d8da 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -1008,24 +1008,13 @@ void __init srmmu_paging_init(void)
 	kmap_init();
 
 	{
-		unsigned long zones_size[MAX_NR_ZONES];
-		unsigned long zholes_size[MAX_NR_ZONES];
-		unsigned long npages;
-		int znum;
+		unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };
 
-		for (znum = 0; znum < MAX_NR_ZONES; znum++)
-			zones_size[znum] = zholes_size[znum] = 0;
+		max_zone_pfn[ZONE_DMA] = max_low_pfn;
+		max_zone_pfn[ZONE_NORMAL] = max_low_pfn;
+		max_zone_pfn[ZONE_HIGHMEM] = highend_pfn;
 
-		npages = max_low_pfn - pfn_base;
-
-		zones_size[ZONE_DMA] = npages;
-		zholes_size[ZONE_DMA] = npages - pages_avail;
-
-		npages = highend_pfn - max_low_pfn;
-		zones_size[ZONE_HIGHMEM] = npages;
-		zholes_size[ZONE_HIGHMEM] = npages - calc_highpages();
-
-		free_area_init_node(0, zones_size, pfn_base, zholes_size);
+		free_area_init(max_zone_pfn);
 	}
 }
 
-- 
2.26.1


^ permalink raw reply related

* [PATCH v2 11/20] parisc: simplify detection of memory zone boundaries
From: Mike Rapoport @ 2020-04-29 12:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
	Heiko Carstens, Michal Hocko, James E.J. Bottomley, Max Filippov,
	Guo Ren, linux-csky, linux-parisc, sparclinux, linux-hexagon,
	linux-riscv, Mike Rapoport, Greg Ungerer, linux-arch, linux-s390,
	linux-c6x-dev, Baoquan He, Jonathan Corbet, linux-sh,
	Helge Deller, x86, Russell King, Ley Foon Tan, Yoshinori Sato,
	Geert Uytterhoeven, linux-arm-kernel, Mark Salter, Matt Turner,
	linux-snps-arc, uclinux-h8-devel, linux-xtensa, linux-alpha,
	linux-um, linux-m68k, Tony Luck, Qian Cai, Greentime Hu,
	Paul Walmsley, Stafford Horne, Guan Xuetao, Hoan Tran,
	Michal Simek, Thomas Bogendoerfer, Brian Cain, Nick Hu, linux-mm,
	Vineet Gupta, linux-mips, openrisc, Richard Weinberger,
	Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200429121126.17989-1-rppt@kernel.org>

From: Mike Rapoport <rppt@linux.ibm.com>

The free_area_init() function only requires the definition of maximal PFN
for each of the supported zone rater than calculation of actual zone sizes
and the sizes of the holes between the zones.

After removal of CONFIG_HAVE_MEMBLOCK_NODE_MAP the free_area_init() is
available to all architectures.

Using this function instead of free_area_init_node() simplifies the zone
detection.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/parisc/mm/init.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c
index 5224fb38d766..02d2fdb85dcc 100644
--- a/arch/parisc/mm/init.c
+++ b/arch/parisc/mm/init.c
@@ -675,27 +675,11 @@ static void __init gateway_init(void)
 
 static void __init parisc_bootmem_free(void)
 {
-	unsigned long zones_size[MAX_NR_ZONES] = { 0, };
-	unsigned long holes_size[MAX_NR_ZONES] = { 0, };
-	unsigned long mem_start_pfn = ~0UL, mem_end_pfn = 0, mem_size_pfn = 0;
-	int i;
-
-	for (i = 0; i < npmem_ranges; i++) {
-		unsigned long start = pmem_ranges[i].start_pfn;
-		unsigned long size = pmem_ranges[i].pages;
-		unsigned long end = start + size;
-
-		if (mem_start_pfn > start)
-			mem_start_pfn = start;
-		if (mem_end_pfn < end)
-			mem_end_pfn = end;
-		mem_size_pfn += size;
-	}
+	unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, };
 
-	zones_size[0] = mem_end_pfn - mem_start_pfn;
-	holes_size[0] = zones_size[0] - mem_size_pfn;
+	max_zone_pfn[0] = memblock_end_of_DRAM();
 
-	free_area_init_node(0, zones_size, mem_start_pfn, holes_size);
+	free_area_init(max_zone_pfn);
 }
 
 void __init paging_init(void)
-- 
2.26.1


^ permalink raw reply related

* [PATCH v2 10/20] m68k: mm: simplify detection of memory zone boundaries
From: Mike Rapoport @ 2020-04-29 12:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
	Heiko Carstens, Michal Hocko, James E.J. Bottomley, Max Filippov,
	Guo Ren, linux-csky, linux-parisc, sparclinux, linux-hexagon,
	linux-riscv, Mike Rapoport, Greg Ungerer, linux-arch, linux-s390,
	linux-c6x-dev, Baoquan He, Jonathan Corbet, linux-sh,
	Helge Deller, x86, Russell King, Ley Foon Tan, Yoshinori Sato,
	Geert Uytterhoeven, linux-arm-kernel, Mark Salter, Matt Turner,
	linux-snps-arc, uclinux-h8-devel, linux-xtensa, linux-alpha,
	linux-um, linux-m68k, Tony Luck, Qian Cai, Greentime Hu,
	Paul Walmsley, Stafford Horne, Guan Xuetao, Hoan Tran,
	Michal Simek, Thomas Bogendoerfer, Brian Cain, Nick Hu, linux-mm,
	Vineet Gupta, linux-mips, openrisc, Richard Weinberger,
	Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200429121126.17989-1-rppt@kernel.org>

From: Mike Rapoport <rppt@linux.ibm.com>

The free_area_init() function only requires the definition of maximal PFN
for each of the supported zone rater than calculation of actual zone sizes
and the sizes of the holes between the zones.

After removal of CONFIG_HAVE_MEMBLOCK_NODE_MAP the free_area_init() is
available to all architectures.

Using this function instead of free_area_init_node() simplifies the zone
detection.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
---
 arch/m68k/mm/motorola.c | 11 +++++------
 arch/m68k/mm/sun3mmu.c  | 10 +++-------
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index 84ab5963cabb..904c2a663977 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -365,7 +365,7 @@ static void __init map_node(int node)
  */
 void __init paging_init(void)
 {
-	unsigned long zones_size[MAX_NR_ZONES] = { 0, };
+	unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, };
 	unsigned long min_addr, max_addr;
 	unsigned long addr;
 	int i;
@@ -448,11 +448,10 @@ void __init paging_init(void)
 #ifdef DEBUG
 	printk ("before free_area_init\n");
 #endif
-	for (i = 0; i < m68k_num_memory; i++) {
-		zones_size[ZONE_DMA] = m68k_memory[i].size >> PAGE_SHIFT;
-		free_area_init_node(i, zones_size,
-				    m68k_memory[i].addr >> PAGE_SHIFT, NULL);
+	for (i = 0; i < m68k_num_memory; i++)
 		if (node_present_pages(i))
 			node_set_state(i, N_NORMAL_MEMORY);
-	}
+
+	max_zone_pfn[ZONE_DMA] = memblock_end_of_DRAM();
+	free_area_init(max_zone_pfn);
 }
diff --git a/arch/m68k/mm/sun3mmu.c b/arch/m68k/mm/sun3mmu.c
index eca1c46bb90a..5d8d956d9329 100644
--- a/arch/m68k/mm/sun3mmu.c
+++ b/arch/m68k/mm/sun3mmu.c
@@ -42,7 +42,7 @@ void __init paging_init(void)
 	unsigned long address;
 	unsigned long next_pgtable;
 	unsigned long bootmem_end;
-	unsigned long zones_size[MAX_NR_ZONES] = { 0, };
+	unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, };
 	unsigned long size;
 
 	empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
@@ -89,14 +89,10 @@ void __init paging_init(void)
 	current->mm = NULL;
 
 	/* memory sizing is a hack stolen from motorola.c..  hope it works for us */
-	zones_size[ZONE_DMA] = ((unsigned long)high_memory - PAGE_OFFSET) >> PAGE_SHIFT;
+	max_zone_pfn[ZONE_DMA] = ((unsigned long)high_memory) >> PAGE_SHIFT;
 
 	/* I really wish I knew why the following change made things better...  -- Sam */
-/*	free_area_init(zones_size); */
-	free_area_init_node(0, zones_size,
-			    (__pa(PAGE_OFFSET) >> PAGE_SHIFT) + 1, NULL);
+	free_area_init(max_zone_pfn);
 
 
 }
-
-
-- 
2.26.1


^ 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