tmem: cleanup: drop COMPARE_COPY_PAGE_SSE2

COMPARE_COPY_PAGE_SSE2 never be used in other place, memcpy() is enough.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
tmem: cleanup: drop typedef pfp_t

Using 'struct page_info' directly instead of 'pfp_t' to make code more
straightforward and readable.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
tmem: cleanup: drop typedef tmem_cli_mfn_t

Using 'xen_pfn_t' directly instead of 'tmem_cli_mfn_t' to make code more
readable.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
tmem: cleanup: rename 'tmh_' with 'tmem_'

tmem was designed can be ported to other platform besides xen easily, but I
don't think anybody will port tmem to other platform. And this flexible
character made tmem not easy for understand, there are too many 'tmh_' and
'tmem_' functions and variables.

This patch replace all 'tmh_' functions/variables with 'tmem_' to make code
more readable.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
tmem: cleanup: drop most of the typedefs

There are many typedefs in tmem most of which are useless and make code
unstraightforward.
This patch try to cleanup those typedefs.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
tmem: cleanup: drop function tmem_alloc/free_infra

Useless function can be replaced by xmalloc/xfree directly.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
tmem: cleanup: drop typedef tmem_client_t

Informations in typedef 'tmem_client_t' can be integreated into
'struct client' directly, no need to use a separate struct.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
tmem: cleanup: drop useless wrap functions

_tmem_alloc/free_subpage_thispool() and _tmem_alloc/free_page_thispool() are
useless, replace them with tmem_alloc/free_subpage_thispool() and
tmem_alloc/free_page_thispool() directly.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
tmem: cleanup: drop unused function 'domain_fully_allocated'

Nobody uses this function.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
tmem: cleanup: drop useless '_subpage' wrap functions

There are too many alloc place in tmem which cause the source code is hard too
read.
Most of the alloc path are useless and only referenced only once, this patch
drops 'tmem_alloc_subpage/_thispool' and '_tmem_alloc'.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
tmem: cleanup: drop useless functions

Function tmem_release_avail_pages_to_host() and tmem_scrub_page() only used
once, no need to separate them out.

Signed-off-by: Bob Liu <bob.liu@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Merge branch 'for-4.4.tmem' of git://xenbits.xen.org/people/konradwilk/xen into staging
xen: arm: remove /xen-core-devices node from dom0 dtb

The intention of adding this node to contain the GIC, timer and memory nodes
(in 1c08d6004ea7) was to allow us to control the #address-cells and

However in the case of the memory node the #*-cells are always taken from the
root node (see ePAPR 3.1, "the following nodes shall be present at the root...
memory node"). This caused breakage on the arndale platform.

In addition it is not valid to just create sub-nodes like this. Unless they
declare themselves as a bus then they will not necessarily be enumerated
(although Linux currently does so in practice).

Therefore:
 - Move the memory node back to the top level.
 - Insert the timer and primary gic nodes in the same location as the host
   DTB, replacing the originals. Note that the nodes here may be marked as in
   use by Xen and therefore the check must be before we discard nodes used by
   Xen.
 - Drop any secondary gics.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Tested-by: Julien Grall <julien.grall@linaro.org>
xen: arm: correct name of the dt node passed around when building dom0 DT

In the case of the GIC, timer and write_properties the argument is the node,
not the parent. Rename the argument to "node" in this case.

I think this stems from the use of the name "np" in other places (confusing
"node parent" for "node pointer").  Therefore replace all uses of "np" with
"node".

In addition in write_properties now that np=>node the name pp makes no sense.
Rename it to "prop".

No semantic change.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
xen: arm: early logging of command line

Helpful for diagnosis of bad console= parameters.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
evtchn/fifo: only set READY for new heads

Setting a queue's READY bit for every event added to the queue
introduces a race.

If an event is added to the tail of a queue, the guest may consume the
newly added event and leave an empty queue before the READY is set.
The guest may then see a stale HEAD value and if the event at the
stale head became linked onto a different queue, the guest would
consume events from the wrong queue (corrupting it).

As noted in section 4.1.2 of the design document, only set READY if a
new HEAD is set.  This ensures that if the guest sees a READY bit set
the corresponding HEAD is valid.

Signed-off-by: David Vrabel <david.vrabel@citrix.com>
x86/pvh: clearly specify used parameters in vcpu_guest_context

The aim of this patch is to define a stable way in which PVH is
going to do AP bringup.

Since we are running inside of a HVM container, PVH should only need
to set flags, cr3 and user_regs in order to bring up a vCPU, the rest
can be set once the vCPU is started using the bare metal methods.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: George Dunlap <george.dunlap@eu.citrix.com>
x86/xsave: fix nonlazy state handling

Nonlazy xstates should be xsaved each time when vcpu_save_fpu.
Operation to nonlazy xstates will not trigger #NM exception, so
whenever vcpu scheduled in it got restored and whenever scheduled
out it should get saved.

Currently this bug affects AMD LWP feature, and later Intel MPX
feature. With the bugfix both LWP and MPX will work fine.

Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>

Furthermore, during restore we also need to set nonlazy_xstate_used
according to the incoming accumulated XCR0.

Also adjust the changes to i387.c such that there won't be a pointless
clts()/stts() pair.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
x86/pvh: change epte_get_entry_emt() for pvh mem types

For pvh guests, epte_get_entry_emt() is incorrectly returning WB for
all mem types because of the following check:
    if ( !v->domain->arch.hvm_domain.params[HVM_PARAM_IDENT_PT] )
Skip the check for pvh guests.

Also note, MTRR ranges are not maintained for pvh, and a solution is
being contrived using PAT.

Signed-off-by: Mukesh Rathor <mukesh.rathor@oracle.com>
Reviewed-off-by: Jan Beulich <jbeulich@suse.com>
tools/xc_restore: Initialise console and store mfns

If the console or store mfn chunks are not present in the migration stream,
stack junk gets reported for the mfns.

XenServer had a very hard to track down VM corruption issue caused by exactly
this issue.  Xenconsoled would connect to a junk mfn and incremented the ring
pointer if the junk happend to look like a valid gfn.

Coverity ID: 1056093 1056094

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Ian Campbell <Ian.Campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>