Commit Graph

1064070 Commits

Author SHA1 Message Date
Eric Biggers
320dfca58a ANDROID: fips140: fix in-tree builds
Kernel code is expected to support both in-tree and out-of-tree builds.
Fix in-tree builds of the fips140 module by using the full include path
for fips140-defs.h.

Bug: 188620248
Change-Id: Iba5ed888bc6a316bd4d0a97479768f50094d63d0
Signed-off-by: Eric Biggers <ebiggers@google.com>
2023-01-09 21:19:29 +00:00
Eric Biggers
57be8919bf ANDROID: fips140: consolidate linker script changes into module.lds.S
The customizations to the module linker script required by the fips140
module are currently split between scripts/module.lds.S and a file it
includes, arch/arm64/include/asm/module.lds.h.  There isn't actually
anything architecture-specific about the part that was put into the
architecture-specific file, though.  Let's move that part into
scripts/module.lds.S so that the fips140 changes are in the same file.

Bug: 188620248
Change-Id: If559a216e026d2107cdf3291b487686fdb21a5e8
Signed-off-by: Eric Biggers <ebiggers@google.com>
2023-01-09 21:19:29 +00:00
Will Deacon
84e88b2554 Revert "ANDROID: KVM: arm64: Make gen-hyprel emit delimiters"
This reverts commit 9cb398bd05.

The '__hyprel_{start,end}' symbols are no longer used, so don't bother
generating them.

Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 261855285
Change-Id: I8e8dc5c94a9e67400e73e362e4377032328d86d4
2023-01-09 13:25:34 +00:00
Will Deacon
ace5025390 ANDROID: KVM: arm64: Resolve hyp module addresses using ELF sections
Resolving the addresses of the hypervisor sections within a loadable
module using symbol assignment is fragile, particularly in the face of
mergeable sections (i.e. those emitted with SHF_MERGE by the compiler).

Instead, parse the ELF .hyp.* sections directly and remove the need for
global symbols in the hypervisor module linker script.

Signed-off-by: Will Deacon <will@kernel.org>
[will: Preserve function_nocfi() calls which aren't needed in android14-6.1]
Signed-off-by: Will Deacon <willdeacon@google.com>
Bug: 261855285
Change-Id: I91d88e1a341b91ffe52ffc770dddc9b46ccb3aa4
2023-01-09 13:25:34 +00:00
Ray Chi
19b5efdcd2 ANDROID: usb: gadget: f_accessory: update SS/SSP descriptors
Currently, only HS descriptors will be updated with endpoint address
during binding process. According to current max_speed in configfs,
this patch will also update SS/SSP descriptors with endpoint address.

Bug: 162562782
Signed-off-by: Ray Chi <raychi@google.com>
Change-Id: I67983ef47df7ac567ec1d3af80921c39c98a545d
(cherry picked from commit 41fe558317)
(cherry picked from commit ba3ec687b7)
2023-01-07 07:01:58 +00:00
Arthur Simchaev
b6f0e756f3 FROMGIT: scsi: ufs: core: Remove ufshcd_map_desc_id_to_length()
There shouldn't be any restriction of the descriptor size (not the
descriptor id for that matter) up to QUERY_DESC_MAX_SIZE.  According to the
spec, the caller can use any descriptor size, and it is up to the device to
return the actual size.  Therefore there shouldn't be any sizes hardcoded
in the kernel, nor any need to cache it, hence the
ufshcd_map_desc_id_to_length() function is redundant. Always read the
descriptors with QUERY_DESC_MAX_SIZE size.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Suggested-by: Bean Huo <beanhuo@micron.com>
Change-Id: I7933da0b7ec3771b9faccb2c8fe05bb83f741162
Signed-off-by: Arthur Simchaev <Arthur.Simchaev@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 16ed9d312b git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Arthur Simchaev
dc7535fef3 FROMGIT: scsi: ufs: core: Remove len parameter from ufshcd_set_active_icc_lvl()
len argument is not used anymore in ufshcd_set_active_icc_lvl() function.

Change-Id: I351a36061dbc0f2f61bae371892c2de2fed3dcc1
Signed-off-by: Arthur Simchaev <Arthur.Simchaev@wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 01a0d515b7 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Arthur Simchaev
9f22f90859 FROMGIT: scsi: ufs: core: Remove redundant desc_size variable from hba
Always read the descriptor with QUERY_DESC_MAX_SIZE.  According to the
spec, the device returns the actual size.

Change-Id: I29053a66d1f65f674fba6d7e1a6c6e7f546eec74
Signed-off-by: Arthur Simchaev <Arthur.Simchaev@wdc.com>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit f2a89b071b git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Arthur Simchaev
a79e70f8f0 FROMGIT: scsi: ufs: core: Remove redundant wb check
We used to use the extended-feature field in the device descriptor as an
indication that the device supported UFS 2.2 or later.  Remove that as this
check is specifically done few lines above.

Change-Id: I3291740eb846215c87cefe36c60fe09a7f4f2856
Signed-off-by: Arthur Simchaev <Arthur.Simchaev@wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 358ae02f47 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Andrew Halaney
be5a0dde3f FROMGIT: scsi: ufs: ufs-qcom: Use dev_err() where possible
dev_err() statements are better to use than pr_err(), so switch to those.

In a similar vein, the check on the dev_req_params pointer here is not
needed, the two places this function is called never pass in a NULL
pointer, so instead of using dev_err() there just remove it.

Change-Id: I012f6a6d02f00a4295dab59ffb6772dce3f77149
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Asutosh Das <quic_asutoshd@quicinc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 1026f7d366 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Andrew Halaney
247c00e268 FROMGIT: scsi: ufs: ufs-qcom: Remove usage of dbg_print_en
This bitmask is unconditionally set in the current driver, so all
conditionals using it can be considered bit rot.

Let's take the current default conditional path everywhere and remove
dbg_print_en from the driver.

Change-Id: I7b83c8a11829963efacadd9969b50d3eeb4ec177
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Asutosh Das <quic_asutoshd@quicinc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit e4ce23fba3 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Andrew Halaney
a0cf14fcb7 FROMGIT: scsi: ufs: ufs-qcom: Clean up dbg_register_dump
The current implementation has abstractions that don't give any benefits.

The print_fn callback (and its only callback implementation,
ufs_qcom_dump_regs_wrapper()) was only used by
ufs_qcom_print_hw_debug_reg_all() and just multiplies len by 4 before
calling ufshcd_dump_regs().

ufs_qcom_print_hw_debug_reg_all() is only called by
ufs_qcom_dump_dbg_regs().

There's no real gain in those abstractions, so let's just do the work
directly in ufs_qcom_dump_dbg_regs() (the dbg_register_dump callback).

Change-Id: I5085c094e56319ea519c2e6e0a28f97be49e4a30
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Asutosh Das <quic_asutoshd@quicinc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 50a427a00c git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Andrew Halaney
52275e5566 FROMGIT: scsi: ufs: ufs-qcom: Drop unnecessary NULL checks
This code path is only called through one function, and the HBA struct is
already accessed in ufshcd_vops_dbg_register_dump() prior to calling so
there is no way for it to be NULL.

Likewise, the print_fn callback is always supplied within this driver and
is always provided.

Change-Id: I7c0b84767d094568e998bcfa11008a2e19c0554b
Signed-off-by: Andrew Halaney <ahalaney@redhat.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Asutosh Das <quic_asutoshd@quicinc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 921a880827 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Bean Huo
abfb939cd7 FROMGIT: scsi: ufs: core: bsg: Add advanced RPMB support in ufs_bsg
Add advanced RPMB support in ufs_bsg:

 1. According to the UFS specification, only one RPMB operation can be
    performed at any time. We can ensure this by using reserved slot and
    its dev_cmd sync operation protection mechanism.

 2. For Advanced RPMB, RPMB metadata is packaged in an EHS (Extra Header
    Segment) of a command UPIU, and the corresponding reply EHS (from the
    device) should also be returned to the user space.  bsg_job->request
    and bsg_job->reply allow us to pass and return EHS from/back to
    userspace.

Compared to normal/legacy RPMB, the advantages of advanced RPMB are:

 1. The data length in the Advanced RPMB data read/write command can be
    larger than 4KB. For the legacy RPMB, the data length in a single RPMB
    data transfer is 256 bytes.

 2. All of the advanced RPMB operations will be a single command. For
    legacy RPMB, take the read write-counter value as an example, you need
    two commands (first SECURITY PROTOCOL OUT, then second SECURITY
    PROTOCOL IN).

Change-Id: Iefadc64abb18c1dd6ac5e416ed692be9b7019d71
Signed-off-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 6ff265fc5e git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Bean Huo
9cd7495143 FROMGIT: scsi: ufs: core: Pass EHS length into ufshcd_prepare_req_desc_hdr()
We need to fill in the total EHS length in UTP Transfer Request Descriptor.
Add this functionality to ufshcd_prepare_req_desc_hdr().

Change-Id: Ifdc93e0877226d437daae95e7385b26d899188d4
Signed-off-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit a4b1c9b9b3 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Bean Huo
efa542a826 FROMGIT: scsi: ufs: core: Advanced RPMB detection
Check UFS Advanced RPMB LU enablement during ufshcd_lu_init().

Change-Id: Ib923917dd9144f824bc08e4b600e6fd54e1716a5
Signed-off-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit f6b9d0fe5c git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Bean Huo
7242e938ec FROMGIT: scsi: ufs: core: Split ufshcd_map_sg()
Take out the "map scatter-gather list to prdt" part of the code in
ufshcd_map_sg() and split it into a new function ufshcd_sgl_to_prdt().

Change-Id: Idd40c405ab09cb1154eae17abcd921b0ea0013c9
Signed-off-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 7a4df79d0b git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Bean Huo
7169b86bdc FROMGIT: scsi: ufs: bsg: Clean up ufs_bsg_request()
Move sg_copy_from_buffer() below its associated case statement.

Change-Id: I19ed06bfb20ca3e62a37843fcbdd73b118a0ee3a
Signed-off-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 765ab00dac git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Bean Huo
1afc13288c FROMGIT: scsi: ufs: bsg: Remove unnecessary length checkup
Remove checks on job->request_len and job->reply_len because msgcode checks
in a subseqent commit will rule out malicious requests.

Change-Id: I62580fb6e8facf3983d51664e69c821db0bc5684
Signed-off-by: Bean Huo <beanhuo@micron.com>
Acked-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Bug: 258234315
(cherry picked from commit 64d4864714 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Keoseong Park
7ca2a56cd5 UPSTREAM: scsi: ufs: core: Fix typo in comment
Change "drity" to "dirty".

Change-Id: Id1d5a96b6053a92243b262e3e4b80ef2388d440d
Signed-off-by: Keoseong Park <keosung.park@samsung.com>
Link: https://lore.kernel.org/r/20221019034530epcms2p2b10e072bb66b3fd6cdbe0e2423c11735@epcms2p2
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 307539eed4)
Bug: 258234315
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Keoseong Park
8e7917293d UPSTREAM: scsi: ufs: core: Fix typo for register name in comments
Change "UTRMLCLR" to "UTMRLCLR". The meaning is "UTP Task Management
Request List CLear Register"

Change-Id: Ieb4f4d4b1edac2f79ca9c987611da0f0617f15f2
Signed-off-by: Keoseong Park <keosung.park@samsung.com>
Link: https://lore.kernel.org/r/20221017095815epcms2p110e3421b99bb9a937620b4d065d0ed12@epcms2p1
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 4652b58fe3)
Bug: 258234315
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Dukhyun Kwon
0229e633d2 UPSTREAM: scsi: ufs: core: Fix the error log in ufshcd_query_flag_retry()
In ufshcd_query_flag_retry() failed log is incorrectly output as
"ufs attibute".

Change-Id: I66e5adbae17530633b2d96751c6eaefa45d85a61
Signed-off-by: Dukhyun Kwon <d_hyun.kwon@samsung.com>
Link: https://lore.kernel.org/r/1891546521.01666080182092.JavaMail.epsvc@epcpadp4
Reviewed-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 48ee795280)
Bug: 258234315
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Markus Fuchs
96e26e259e UPSTREAM: scsi: ufs: core: Remove unneeded casts from void *
The end_io_data member of the "struct request" type has type "void *", so
no cast is necessary.

Link: https://lore.kernel.org/r/20220928222241.131334-1-mklntf@gmail.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Change-Id: Ie26a005992dbe69e08f2db295ac881934cf51b9a
Signed-off-by: Markus Fuchs <mklntf@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 67d0a917fb)
Bug: 258234315
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Shang XiaoJing
7a770175ad UPSTREAM: scsi: ufs: qcom: Remove redundant dev_err() call
devm_ioremap_resource() already prints an error message. Remove the
redundant dev_err() call.

Link: https://lore.kernel.org/r/20220923101217.18345-1-shangxiaojing@huawei.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Change-Id: I05cf7f73e059bd278ca2ec80278438c47d99fa55
Signed-off-by: Shang XiaoJing <shangxiaojing@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 07e433614c)
Bug: 258234315
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Bart Van Assche
1ac96bd1cc ANDROID: scsi: ufs: Minimize diffs with the upstream code
Bug: 258234315
Change-Id: I33a5eb205be59a0ede0afcdca6f7f4c5d9925a67
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2023-01-06 22:40:58 +00:00
Isaac J. Manjarres
b5370de5c8 ANDROID: kbuild: Search external devicetree path when running clean target
When running the clean target, kbuild is supposed to remove dtbs and
dtbos. However, kbuild only searches for those devicetree build
artifacts in the directory that the kernel binaries or kernel modules
are output to. This is not sufficient in cases where an external
devicetree is used, so include the external devicetree path when
searching for dtb and dtbo build artifacts.

Bug: 264602319
Fixes: 3d42cc9e75 ("ANDROID: kbuild: add support for compiling external device trees")
Change-Id: I45fdfdef09c3d57401d98e5db731273147d7d265
Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com>
2023-01-06 20:01:12 +00:00
Mostafa Saleh
09b9571931 ANDROID: arm64: kvm: iommu: Export IOMMU register and init functions.
As S2MPU driver was moved to an EL2 module, we need to export init
and register functions to be used from the module.

Bug: 261857213
Change-Id: I819dff0e6164051c464533d80eb68ea003b34b21
Signed-off-by: Mostafa Saleh <smostafa@google.com>
2023-01-06 19:32:46 +00:00
Mostafa Saleh
c6c355efc2 ANDROID: arm64: kvm: Add new module functions used by s2mpu.
Add functions needed by S2MPU el2 module:
 -pkvm_host_donate_hyp/pkvm_hyp_donate_host: get and return SMPT from
  host kernel.
 -memcpy/memset: common functions used by s2mpu module.
 -hyp_pa: convert hyp address to PA, to get DMA address of SMPT.
 -kern_hyp_va: convert kernel address to hyp VA, used by the
  module to get the VA of SMPTs allocated from the kernel.

Bug: 261857213
Change-Id: Idceccf0ac38444e7f267f50c476b99f01a613372
Signed-off-by: Mostafa Saleh <smostafa@google.com>
2023-01-06 19:32:46 +00:00
Mostafa Saleh
3f06d93b21 ANDROID: Remove S2MPU symbols
As S2MPU driver is removed from common kernel, remove it's symbols.

Bug: 261857213
Change-Id: I7c70f656ffe9c8555fba1085dae29ac8c5de0f5e
Signed-off-by: Mostafa Saleh <smostafa@google.com>
2023-01-06 19:32:46 +00:00
Mostafa Saleh
c23a3ead09 ANDROID: arm64: kvm: s2mpu: Update address of s2mpu struct
As the the s2mpu el2 driver is loaded at run time, we can't convert
its address from kernel to hyp using kern_hyp_va.

The kernel module will be responsible of sending the address of the
struct as hyp address in s2mpu hypercalls, currently the load address
of the modules is returned as the token of the module.

Although the passed arguments is the driver struct address, but the
address passed is not a kernel address, so pass it as u64 to avoid
confusing it as a kernel address.

Bug: 261857213
Change-Id: Ieb787f83d7c07ada2c8565f0e34cdc6de71aff6f
Signed-off-by: Mostafa Saleh <smostafa@google.com>
2023-01-06 19:32:46 +00:00
Mostafa Saleh
12bbef61d8 ANDROID: arm64: kvm: s2mpu: Remove S2MPU pKVM driver
As S2MPU driver is used by a few devices and EL2 loadable modules
code is merged.
S2MPU pKVM driver will be moved to be an EL2 module.
This commit removes all the code and configuration for the driver.

Bug: 261857213
Change-Id: I53da660f8503c4bedf2fc48a90d1e8ba73329c05
Signed-off-by: Mostafa Saleh <smostafa@google.com>
2023-01-06 19:32:46 +00:00
Eric Biggers
685a2ade28 ANDROID: fips140: add crypto_memneq() back to the module
crypto_memneq() is one of the utility functions that was intentionally
included in the fips140 module, out of concerns that it would be seen as
"cryptographic" and thus would be required to be included the module for
the FIPS certification.  It should not have been removed from the
module, so add it back.

Bug: 188620248
Fixes: 916c8c836f ("ANDROID: FIPS: remove memneq.o from the list of objects for the fips module")
Change-Id: I8a19dfd73390f8c1348885f97fa42d900e47b82b
Signed-off-by: Eric Biggers <ebiggers@google.com>
2023-01-06 17:59:57 +00:00
Sebastian Ene
bfb3b4dd79 Revert "ANDROID: KVM: arm64: Coalesce host stage2 entries on ownership reclaim"
This reverts commit aeac190b3b.

Bug: 264333547
Test: /data/local/tmp/sebastianene/tests/test_host_app
Change-Id: Id88b705dd725cc8720913fd2909030c2f2fb597f
Signed-off-by: Sebastian Ene <sebastianene@google.com>
2023-01-06 15:31:18 +00:00
Greg Kroah-Hartman
a12422f8c9 Revert "ANDROID: Update the ABI representation"
This reverts commit 8a57e65659.

Reason for revert: This symbol "PageMovable" should not be used by
any driver and is being removed from upstream.

Bug: 264353898
Bug: 261718474
Cc: Jörg Wagner <jorwag@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I368f30bd4ab1f28480ee37e3ee10df9dbb2f5744
2023-01-06 14:57:16 +00:00
Eric Biggers
260c9e9558 ANDROID: fips140: add dump_jitterentropy command to fips140_lab_util
For the entropy analysis, we must provide some output from the Jitter
RNG: a large amount of output from one instance, and a smaller amount of
output from each of a certain number of instances.

The original plan was to use a build of the userspace jitterentropy
library that matches the kernel's jitterentropy_rng as closely as
possible.  However, it's now being requested that the output be gotten
from the kernel instead.

Now that fips140_lab_util depends on AF_ALG anyway, it's straightforward
to dump output from jitterentropy_rng instances using AF_ALG.
Therefore, add a command dump_jitterentropy which supports this.

Bug: 188620248
Change-Id: I78eb26250e88f2fc28fc44aa201acbe5b84df8bb
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit dc01503266)
2023-01-06 13:19:15 +00:00
Charan Teja Kalla
c41503e313 ANDROID: page_pinner: prevent pp_buffer uninitialized access
There is a race window between page_pinner_inited set and the pp_buffer
initialization which cause accessing the pp_buffer->lock. Avoid this by
moving the pp_buffer initialization to page_ext_ops->init() which sets
the page_pinner_inited only after the pp_buffer is initialized.

Race scenario:
1) init_page_pinner is called --> page_pinner_inited is set.

2) __alloc_contig_migrate_range --> __page_pinner_failure_detect()
accesses the pp_buffer->lock(yet to be initialized).

3) Then the pp_buffer is allocated and initialized.

Below is the issue call stack:
 spin_bug+0x0
 _raw_spin_lock_irqsave+0x3c
 __page_pinner_failure_detect+0x110
 __alloc_contig_migrate_range+0x1c4
 alloc_contig_range+0x130
 cma_alloc+0x170
 dma_alloc_contiguous+0xa0
 __dma_direct_alloc_pages+0x16c
 dma_direct_alloc+0x88

Bug: 259024332
Change-Id: I6849ac4d944498b9a431b47cad7adc7903c9bbaa
Signed-off-by: Charan Teja Kalla <quic_charante@quicinc.com>
2023-01-05 19:14:46 +00:00
Jörg Wagner
8a57e65659 ANDROID: Update the ABI representation
1 function symbol(s) added
  'int PageMovable(struct page *)'

Bug: 264353898
Bug: 261718474

Signed-off-by: Jörg Wagner <jorwag@google.com>
Change-Id: I33d4ff94006b42c650b72825353d6eafe101d612
(cherry picked from commit f714a01629b9da755252ff53f1825a2362bfa551)
2023-01-05 19:05:16 +00:00
Yosry Ahmed
c4885d55bc UPSTREAM: proc/meminfo: fix spacing in SecPageTables
SecPageTables has a tab after it instead of a space, this can break
fragile parsers that depend on spaces after the stat names.

Link: https://lkml.kernel.org/r/20221117043247.133294-1-yosryahmed@google.com
Fixes: ebc97a52b5 ("mm: add NR_SECONDARY_PAGETABLE to count secondary page table uses.")
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Shakeel Butt <shakeelb@google.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Sean Christopherson <seanjc@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry-picked from commit f850c84948)
Change-Id: I7b42580b6465c176e44568496755ad5f629572c2
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
 [sumits: This also helps fix failure with VtsKernelProcFileApiTest.test_ProcMemInfoTest
  with android14-5.15. since the patch being fixed was backported via 16976e21d2e68ebbcd]
2023-01-05 18:21:26 +00:00
Jaegeuk Kim
d68a75b1dc Merge "Merge remote-tracking branch 'aosp/upstream-f2fs-stable-linux-5.15.y' into android14-5.15" into android14-5.15 2023-01-05 17:17:32 +00:00
Martin Liu
d705ab99ab ANDROID: vendor_hooks: Export direct reclaim trace points
Get direct reclaim info.

Bug: 190795589
Signed-off-by: Martin Liu <liumartin@google.com>
Change-Id: Ie66a3c87484a364a918c19b8e044c82f1afd6749
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit 12902c9996)
2023-01-05 04:05:51 +00:00
Martin Liu
c20204c67d ANDROID: cma: allow to use CMA in swap-in path
Now, we allow to use CMA pages for certain user space
allocations. One of them is anonymous page fault case.
To align the use case, we should also allow to use CMA
pages in swap-in cases. This could help mitigate OOM
on swap-in cases showing plenty of free CMA left.

logd.klogd invoked oom-killer: gfp_mask=0x1100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=-1000
CPU: 0 PID: 433 Comm: logd.klogd Tainted: G        W  OE     5.10.100-android13-0 #1

Call trace:
 dump_backtrace.cfi_jt+0x0/0x8
 show_stack+0x1c/0x2c
 dump_stack_lvl+0xc0/0x13c
 dump_header+0x54/0x238
 oom_kill_process+0xb0/0x158
 out_of_memory+0x17c/0x328
 __alloc_pages_slowpath+0x5c4/0x8d0
 __alloc_pages_nodemask+0x1bc/0x2e0
 __read_swap_cache_async+0xdc/0x370
 swap_vma_readahead+0x3b4/0x488
 swapin_readahead+0x3c/0x54
 do_swap_page+0x1e0/0xaa0
 handle_pte_fault+0x128/0x1e0
 handle_mm_fault+0x308/0x590
 do_page_fault+0x33c/0x478
 do_translation_fault+0x58/0x11c
 do_mem_abort+0x68/0x144
 el0_da+0x24/0x34
 el0_sync_handler+0xc4/0xec
 el0_sync+0x1c0/0x200
Mem-Info:
active_anon:0 inactive_anon:3222 isolated_anon:62
 active_file:232 inactive_file:428 isolated_file:0
 unevictable:37232 dirty:3 writeback:40
 slab_reclaimable:19943 slab_unreclaimable:281193
 mapped:37126 shmem:2815 pagetables:8981 bounce:0
 free:126007 free_pcp:223 free_cma:123062
Node 0 active_anon:16kB inactive_anon:13160kB active_file:292kB inactive_file:2000kB unevictable:148928kB isolated(anon):0kB isolated(file):0kB mapped:148308kB dirty:12kB writeback:164kB shmem:11260kB shmem_thp: 0kB shmem_pmdmapped: 0kB anon_thp: 0kB writeback_tmp:0kB kernel_stack:20528kB shadow_call_stack:5200kB all_unreclaimable? no
DMA32 free:14128kB min:7572kB low:22636kB high:37700kB reserved_highatomic:4096KB active_anon:0kB inactive_anon:0kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:1913856kB managed:1553276kB mlocked:0kB pagetables:1292kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:2520kB
lowmem_reserve[]: 0 0 0
Normal free:489888kB min:19808kB low:59220kB high:98632kB reserved_highatomic:36864KB active_anon:20kB inactive_anon:12168kB active_file:0kB inactive_file:1640kB unevictable:148928kB writepending:180kB present:4194304kB managed:4063392kB mlocked:148928kB pagetables:34632kB bounce:0kB free_pcp:1928kB local_pcp:0kB free_cma:489752kB
lowmem_reserve[]: 0 0 0
DMA32: 166*4kB (UME) 163*8kB (UMECH) 592*16kB (UMCH) 5*32kB (UC) 2*64kB (C) 2*128kB (C) 2*256kB (C) 1*512kB (C) 1*1024kB (C) 0*2048kB 0*4096kB = 14032kB
Normal: 969*4kB (C) 77*8kB (C) 40*16kB (C) 17*32kB (C) 5*64kB (C) 1*128kB (C) 2*256kB (C) 1*512kB (C) 0*1024kB 0*2048kB 118*4096kB (C) = 490476kB
40220 total pagecache pages
30 pages in swap cache
Swap cache stats: add 2634625, delete 2635304, find 160621/2963954
Free swap  = 1473788kB
Total swap = 2097148kB

Bug: 229822798
Signed-off-by: Martin Liu <liumartin@google.com>
Change-Id: Ia0bb6f72e52f77f26062e1769bfd92e831f07cab
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit 3e591c63b1)
2023-01-05 02:16:50 +00:00
Minchan Kim
dd887dbfaa ANDROID: mm: do not count cma_alloc_fail on __GFP_NORETRY
Do not account __GFP_NORETRY allocation failure as cma_alloc_fail
since it's not critical failure(i.e., the caller with __GFP_NORETRY
should always carry on the fallback plan). It's also good for
compatibility POV with upstream since upstream cma_alloc_fail
only counts cma_alloc_fail with !__GFP_NORETRY since upstream
doesn't support __GFP_NORTRY yet.

Bug: 220669548
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I377e6b033c3786e10b6b1c814037a4fc40e20a73
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit 8ffc7ff817)
2023-01-05 02:16:50 +00:00
Minchan Kim
bb7b81497d ANDROID: GKI: export cma_get_size
Export cma_get_size to tell cma instance's size, which is needed
to allocate entire pages of the cma.

Bug: 218731671
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Ifb2769f60250ce605236342b950907218e1c28a5
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit 7a44906686)
2023-01-05 02:16:50 +00:00
Minchan Kim
1b38e981db ANDROID: mm: cma do not sleep for __GFP_NORETRY
Do not sleep for retrying for __GFP_NORERY since it's failfast
mode approach. User could retry the allocation without the flag
by themselves if they see the failure.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Ic6a857978fda8e353b9ed770d1e0ba1808fd201e
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit 12f48605e8)
2023-01-05 02:16:50 +00:00
Minchan Kim
60d2dad38e ANDROID: mm: cma: skip problematic pageblock
alloc_contig_range is supposed to work on max(MAX_ORDER_NR_PAGES,
or pageblock_nr_pages) granularity aligned range. If it fails
at a page and return error to user, user doesn't know what page
makes the allocation failure and keep retrying another allocation
with new range including the failed page and encountered error
again and again until it could escape the out of the granularity
block. Instead, let's make CMA aware of what pfn was troubled in
previous trial and then continue to work new pageblock out of the
failed page so it doesn't see the repeated error repeatedly.

Currently, this option works for only __GFP_NORETRY case for
safe for existing CMA users.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I0959c9df3d4b36408a68920abbb4d52d31026079
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit 0e688e972d)
2023-01-05 02:16:50 +00:00
Minchan Kim
c63e78a29a ANDROID: mm: lru_cache_disable skips lru cache drainnig
lru_cache_disable is not trivial cost since it should run work
from every cores in the system. Thus, repeated call of the
function whenever alloc_contig_range in the cma's allocation loop
is called is expensive.

This patch makes the lru_cache_disable smarter in that it will
not run __lru_add_drain_all since it knows the cache was already
disabled by someone else.
With that, user of alloc_contig_range can disable the lru cache
in advance in their context so that subsequent alloc_contig_range
for user's operation will avoid the costly function call.

This patch moves lru_cache APIs from swap.h to swap.c and export
it for vendor users.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I23da8599c55db49dc80226285972e4cd80dedcff
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit c8578a3e90)
2023-01-05 02:16:50 +00:00
Minchan Kim
b74eeef409 ANDROID: mm: do not try test_page_isoalte if migration fails
Currently, alloc_contig_range expects that even though a page fails
with -EBUSY from __alloc_contig_migrate_range, it want to check
those failed pages in test_pages_isolated again with hope that
those page would be freed soon so cma allocatoin would be succeeded.
However, it depends on the luck and I found sometimes test_page_isolated
constantly fails at the page repeatedly whenever cma_alloc retried.
Rather than burning out CPU to check the page's status in
test_pages_isolated for GFP_NORETRY allocation, just bail out and
relies on the user what they want to do.
Currently, this option works for only __GFP_NORETRY case for safe
of existing other users.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I9211452be06960dc7d8f854537e53b3fc5262c8e
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit c01ce3b5ef)
2023-01-05 02:16:50 +00:00
Minchan Kim
a7f55c5c73 ANDROID: mm: add cma allocation statistics
alloc_contig_range is the core worker function for CMA allocation
so it has every information to be able to understand allocation
latency. For example, how many pages are migrated, how many time
unmap was needed to migrate pages, how many times it encountered
errors by some reasons.

This patch adds such statistics in the alloc_contig_range and
return it to user so user can use those information to analyize
latency. The cma_alloc is first user for the statistics, which
export the statistics as new trace event(i.e., cma_alloc_info).

It was really usefuli to optimize cma allocation work.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I7be43cc89d11078e2a324d2d06aada6d8e9e1cc9
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit 675e504598)
2023-01-05 02:16:50 +00:00
Minchan Kim
1b2de5aa2d ANDROID: mm: cma: add vendor hoook in cma_alloc()
Add vendor hook for cma_alloc latency measuring.

Bug: 177231781
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Ia2dbb26454bd8f03489389b29b9a6c939d3c2bbb
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit c6e85ea56b)
2023-01-05 02:16:50 +00:00
Minchan Kim
e845c965ad ANDROID: GKI: enable CONFIG_CMA_SYSFS
Since CMA is getting used more widely, it's more important to
keep monitoring CMA statistics for system health since it's
directly related to user experience.

This feature introduces sysfs statistics for CMA, in order to provide
some basic monitoring of the CMA allocator.

     * the number of CMA page successful allocations
     * the number of CMA page allocation failures

These two values allow the user to calculate the allocation
failure rate for each CMA area.

Bug: 179256052
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I5c8dc58a5d195d2e1b2e25628545f7d2a9c3b7df
Signed-off-by: Richard Chang <richardycc@google.com>
(cherry picked from commit f45afb4508)
2023-01-05 02:16:50 +00:00