ntfs3: Add bounds checking to mi_enum_attr()
Subsystems (9)
Sasha Levin
maintainerPATCH 1/17 ntfs3: Add bounds checking to mi_enum_attr()
From: lei lu <[email protected]>
[ Upstream commit 556bdf27c2dd5c74a9caacbe524b943a6cd42d99 ]
Added bounds checking to make sure that every attr don't stray beyond valid memory region.
--- fs/ntfs3/record.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)
fs/ntfs3/record.c +10 -13
@@ -223,28 +223,19 @@ struct ATTRIB *mi_enum_attr(struct mft_inode *mi, struct ATTRIB *attr) prev_type =0 ; attr =Add2Ptr (rec, off); }else { -/* Check if input attr inside record. */ +/* +* We don't need to check previous attr here. There is +* a bounds checking in the previous round. +*/ off =PtrOffset (rec, attr); -if (off >= used) -return NULL ; asize =le32_to_cpu (attr->size); -if (asize <SIZEOF_RESIDENT ) { -/* Impossible 'cause we should not return such attribute. */ -return NULL ; - } - -/* Overflow check. */ -if (off + asize < off) -return NULL ; prev_type =le32_to_cpu (attr->type); attr =Add2Ptr (attr, asize); off += asize; } - asize =le32_to_cpu (attr->size); -/* Can we use the first field (attr->type). */ if (off +8 > used) {static_assert (ALIGN (sizeof (enum ATTR_TYPE ),8 ) ==8 );
@@ -265,6 +256,12 @@ struct ATTRIB *mi_enum_attr(struct mft_inode *mi, struct ATTRIB *attr)if (t32 < prev_type)return NULL ; + asize =le32_to_cpu (attr->size); +if (asize <SIZEOF_RESIDENT ) { +/* Impossible 'cause we should not return such attribute. */ +return NULL ; + } +/* Check overflow and boundary. */ if (off + asize < off || off + asize > used)return NULL ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 2/17 fs/ntfs3: Check if more than chunk-size bytes are written
From: Andrew Ballance <[email protected]>
[ Upstream commit 9931122d04c6d431b2c11b5bb7b10f28584067f0 ]
A incorrectly formatted chunk may decompress into more than LZNT_CHUNK_SIZE bytes and a index out of bounds will occur in s_max_off.
--- fs/ntfs3/lznt.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs3/lznt.c +3 -0
@@ -236,6 +236,9 @@ static inline ssize_t decompress_chunk(u8 *unc, u8 *unc_end, const u8 *cmpr,/* Do decompression until pointers are inside range. */ while (up < unc_end && cmpr < cmpr_end) { +// return err if more than LZNT_CHUNK_SIZE bytes are written +if (up - unc >LZNT_CHUNK_SIZE ) +return -EINVAL ;/* Correct index */ while (unc + s_max_off[index] < up) index +=1 ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 3/17 fs/ntfs3: Fix warning possible deadlock in ntfs_set_state
In reply to Sasha LevinFrom: Konstantin Komarov <[email protected]>
[ Upstream commit 5b2db723455a89dc96743d34d8bdaa23a402db2f ]
Use non-zero subkey to skip analyzer warnings.
--- fs/ntfs3/ntfs_fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/ntfs_fs.h +1 -1
@@ -334,7 +334,7 @@ struct mft_inode {/* Nested class for ntfs_inode::ni_lock. */ enum ntfs_inode_mutex_lock_class { -NTFS_INODE_MUTEX_DIRTY , +NTFS_INODE_MUTEX_DIRTY =1 ,NTFS_INODE_MUTEX_SECURITY ,NTFS_INODE_MUTEX_OBJID ,NTFS_INODE_MUTEX_REPARSE ,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 4/17 fs/ntfs3: Stale inode instead of bad
In reply to Sasha LevinFrom: Konstantin Komarov <[email protected]>
[ Upstream commit 1fd21919de6de245b63066b8ee3cfba92e36f0e9 ]
Fixed the logic of processing inode with wrong sequence number.
--- fs/ntfs3/inode.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
fs/ntfs3/inode.c +7 -3
@@ -532,11 +532,15 @@ struct inode *ntfs_iget5(struct super_block *sb, const struct MFT_REF *ref,if (inode->i_state &I_NEW ) inode =ntfs_read_mft (inode, name, ref);else if (ref->seq !=ntfs_i (inode)->mi.mrec->seq) { -/* Inode overlaps? */ -_ntfs_bad_inode (inode); +/* +* Sequence number is not expected. +* Looks like inode was reused but caller uses the old reference +*/ +iput (inode); + inode =ERR_PTR (-ESTALE ); } -if (IS_ERR (inode) && name) +if (IS_ERR (inode))ntfs_set_state (sb->s_fs_info,NTFS_DIRTY_ERROR );return inode;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 5/17 fs/ntfs3: Add rough attr alloc_size check
In reply to Sasha LevinFrom: Konstantin Komarov <[email protected]>
[ Upstream commit c4a8ba334262e9a5c158d618a4820e1b9c12495c ]
--- fs/ntfs3/record.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ntfs3/record.c +3 -0
@@ -331,6 +331,9 @@ struct ATTRIB *mi_enum_attr(struct mft_inode *mi, struct ATTRIB *attr)if (attr->nres.c_unit)return NULL ; + +if (alloc_size > mi->sbi->volume.size) +return NULL ; }return attr;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 6/17 fs/ntfs3: Fix possible deadlock in mi_read
In reply to Sasha LevinFrom: Konstantin Komarov <[email protected]>
[ Upstream commit 03b097099eef255fbf85ea6a786ae3c91b11f041 ]
Mutex lock with another subclass used in ni_lock_dir().
--- fs/ntfs3/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ntfs3/namei.c +1 -1
@@ -81,7 +81,7 @@ static struct dentry *ntfs_lookup(struct inode *dir, struct dentry *dentry,if (err <0 ) inode =ERR_PTR (err);else { -ni_lock (ni); +ni_lock_dir (ni); inode =dir_search_u (dir, uni,NULL );ni_unlock (ni); }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 7/17 fs/ntfs3: Additional check in ni_clear()
In reply to Sasha LevinFrom: Konstantin Komarov <[email protected]>
[ Upstream commit d178944db36b3369b78a08ba520de109b89bf2a9 ]
Checking of NTFS_FLAGS_LOG_REPLAYING added to prevent access to uninitialized bitmap during replay process.
--- fs/ntfs3/frecord.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ntfs3/frecord.c +3 -1
@@ -102,7 +102,9 @@ void ni_clear(struct ntfs_inode *ni) {struct rb_node *node; -if (!ni->vfs_inode.i_nlink && ni->mi.mrec &&is_rec_inuse (ni->mi.mrec)) +if (!ni->vfs_inode.i_nlink && ni->mi.mrec && +is_rec_inuse (ni->mi.mrec) && + !(ni->mi.sbi->flags &NTFS_FLAGS_LOG_REPLAYING ))ni_delete_all (ni);al_destroy (ni);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 8/17 fs/ntfs3: Fix general protection fault in run_is_mapped_full
In reply to Sasha LevinFrom: Konstantin Komarov <[email protected]>
[ Upstream commit a33fb016e49e37aafab18dc3c8314d6399cb4727 ]
Fixed deleating of a non-resident attribute in ntfs_create_inode() rollback.
--- fs/ntfs3/inode.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/ntfs3/inode.c +4 -1
@@ -1703,7 +1703,10 @@ struct inode *ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir, attr =ni_find_attr (ni,NULL ,NULL ,ATTR_EA ,NULL ,0 ,NULL ,NULL );if (attr && attr->non_res) {/* Delete ATTR_EA, if non-resident. */ -attr_set_size (ni,ATTR_EA ,NULL ,0 ,NULL ,0 ,NULL , false,NULL ); +struct runs_tree run; +run_init (&run); +attr_set_size (ni,ATTR_EA ,NULL ,0 , &run,0 ,NULL , false,NULL ); +run_close (&run); }if (rp_inserted)
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 9/17 fs/ntfs3: Additional check in ntfs_file_release
In reply to Sasha LevinFrom: Konstantin Komarov <[email protected]>
[ Upstream commit 031d6f608290c847ba6378322d0986d08d1a645a ]
--- fs/ntfs3/file.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
fs/ntfs3/file.c +8 -1
@@ -1171,7 +1171,14 @@ static int ntfs_file_release(struct inode *inode, struct file *file)/* If we are last writer on the inode, drop the block reservation. */ if (sbi->options->prealloc && ((file->f_mode &FMODE_WRITE ) && -atomic_read (&inode->i_writecount) ==1 )) { +atomic_read (&inode->i_writecount) ==1 ) +/* +* The only file when inode->i_fop = &ntfs_file_operations and +* init_rwsem(&ni->file.run_lock) is not called explicitly is MFT. +* +* Add additional check here. +*/ + && inode->i_ino !=MFT_REC_MFT ) {ni_lock (ni);down_write (&ni->file.run_lock);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 10/17 scsi: scsi_transport_fc: Allow setting rport state to current state
In reply to Sasha LevinFrom: Benjamin Marzinski <[email protected]>
[ Upstream commit d539a871ae47a1f27a609a62e06093fa69d7ce99 ]
The only input fc_rport_set_marginal_state() currently accepts is "Marginal" when port_state is "Online", and "Online" when the port_state is "Marginal". It should also allow setting port_state to its current state, either "Marginal or "Online".
--- drivers/scsi/scsi_transport_fc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/scsi_transport_fc.c +2 -2
@@ -1255,7 +1255,7 @@ static ssize_t fc_rport_set_marginal_state(struct device *dev,*/ if (rport->port_state ==FC_PORTSTATE_ONLINE ) rport->port_state = port_state; -else +else if (port_state != rport->port_state)return -EINVAL ; }else if (port_state ==FC_PORTSTATE_ONLINE ) {/*
@@ -1265,7 +1265,7 @@ static ssize_t fc_rport_set_marginal_state(struct device *dev,*/ if (rport->port_state ==FC_PORTSTATE_MARGINAL ) rport->port_state = port_state; -else +else if (port_state != rport->port_state)return -EINVAL ; }else return -EINVAL ;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 11/17 cifs: Improve creating native symlinks pointing to directory
In reply to Sasha LevinFrom: Pali Rohár <[email protected]>
[ Upstream commit 3eb40512530e4f64f819d8e723b6f41695dace5a ]
SMB protocol for native symlinks distinguish between symlink to directory and symlink to file. These two symlink types cannot be exchanged, which means that symlink of file type pointing to directory cannot be resolved at all (and vice-versa).
Windows follows this rule for local filesystems (NTFS) and also for SMB.
Linux SMB client currenly creates all native symlinks of file type. Which means that Windows (and some other SMB clients) cannot resolve symlinks pointing to directory created by Linux SMB client.
As Linux system does not distinguish between directory and file symlinks, its API does not provide enough information for Linux SMB client during creating of native symlinks.
Add some heuristic into the Linux SMB client for choosing the correct symlink type during symlink creation. Check if the symlink target location ends with slash, or last path component is dot or dot-dot, and check if the target location on SMB share exists and is a directory. If at least one condition is truth then create a new SMB symlink of directory type. Otherwise create it as file type symlink.
This change improves interoperability with Windows systems. Windows systems would be able to resolve more SMB symlinks created by Linux SMB client which points to existing directory.
--- fs/smb/client/reparse.c | 164 +++++++++++++++++++++++++++++++++++++- fs/smb/client/smb2inode.c | 3 +- fs/smb/client/smb2proto.h | 1 + 3 files changed, 164 insertions(+), 4 deletions(-)
fs/smb/client/reparse.c +161 -3
@@ -14,6 +14,12 @@#include "fs_context.h" #include "reparse.h" +static int detect_directory_symlink_target (struct cifs_sb_info *cifs_sb, +const unsigned int xid, +const char *full_path, +const char *symname, +bool *directory); +int smb2_create_reparse_symlink (const unsigned int xid,struct inode *inode,struct dentry *dentry,struct cifs_tcon *tcon,const char *full_path,const char *symname)
@@ -24,6 +30,7 @@ int smb2_create_reparse_symlink(const unsigned int xid, struct inode *inode,struct inode *new;struct kvec iov;__le16 *path; +bool directory;char *sym, sep =CIFS_DIR_SEP (cifs_sb);u16 len, plen;int rc =0 ;
@@ -45,6 +52,18 @@ int smb2_create_reparse_symlink(const unsigned int xid, struct inode *inode, goto out; } +/* +* SMB distinguish between symlink to directory and symlink to file. +* They cannot be exchanged (symlink of file type which points to +* directory cannot be resolved and vice-versa). Try to detect if +* the symlink target could be a directory or not. When detection +* fails then treat symlink as a file (non-directory) symlink. +*/ + directory = false; + rc =detect_directory_symlink_target (cifs_sb, xid, full_path, symname, &directory); +if (rc <0 ) + goto out; + plen =2 *UniStrnlen ((wchar_t *)path,PATH_MAX ); len =sizeof (*buf) + plen *2 ; buf =kzalloc (len,GFP_KERNEL );
@@ -69,7 +88,8 @@ int smb2_create_reparse_symlink(const unsigned int xid, struct inode *inode, iov.iov_base = buf; iov.iov_len = len; new =smb2_get_reparse_inode (&data, inode->i_sb, xid, - tcon, full_path, &iov,NULL ); + tcon, full_path, directory, + &iov,NULL );if (!IS_ERR (new))d_instantiate (dentry, new);else
@@ -81,6 +101,144 @@ int smb2_create_reparse_symlink(const unsigned int xid, struct inode *inode,return rc; } +static int detect_directory_symlink_target (struct cifs_sb_info *cifs_sb, +const unsigned int xid, +const char *full_path, +const char *symname, +bool *directory) +{ +char sep =CIFS_DIR_SEP (cifs_sb); +struct cifs_open_parms oparms; +struct tcon_link *tlink; +struct cifs_tcon *tcon; +const char *basename; +struct cifs_fid fid; +char *resolved_path; +int full_path_len; +int basename_len; +int symname_len; +char *path_sep; +__u32 oplock; +int open_rc; + +/* +* First do some simple check. If the original Linux symlink target ends +* with slash, or last path component is dot or dot-dot then it is for +* sure symlink to the directory. +*/ + basename =kbasename (symname); + basename_len =strlen (basename); +if (basename_len ==0 ||/* symname ends with slash */ + (basename_len ==1 && basename[0 ] =='.' ) ||/* last component is "." */ + (basename_len ==2 && basename[0 ] =='.' && basename[1 ] =='.' )) {/* or ".." */ + *directory = true; +return 0 ; + } + +/* +* For absolute symlinks it is not possible to determinate +* if it should point to directory or file. +*/ +if (symname[0 ] =='/' ) { +cifs_dbg (FYI , +"%s: cannot determinate if the symlink target path '%s' " +"is directory or not, creating '%s' as file symlink\n" , + __func__, symname, full_path); +return 0 ; + } + +/* +* If it was not detected as directory yet and the symlink is relative +* then try to resolve the path on the SMB server, check if the path +* exists and determinate if it is a directory or not. +*/ + + full_path_len =strlen (full_path); + symname_len =strlen (symname); + + tlink =cifs_sb_tlink (cifs_sb); +if (IS_ERR (tlink)) +return PTR_ERR (tlink); + + resolved_path =kzalloc (full_path_len + symname_len +1 ,GFP_KERNEL ); +if (!resolved_path) { +cifs_put_tlink (tlink); +return -ENOMEM ; + } + +/* +* Compose the resolved SMB symlink path from the SMB full path +* and Linux target symlink path. +*/ +memcpy (resolved_path, full_path, full_path_len+1 ); + path_sep =strrchr (resolved_path, sep); +if (path_sep) + path_sep++; +else + path_sep = resolved_path; +memcpy (path_sep, symname, symname_len+1 ); +if (sep =='\\' ) +convert_delimiter (path_sep, sep); + + tcon =tlink_tcon (tlink); + oparms =CIFS_OPARMS (cifs_sb, tcon, resolved_path, +FILE_READ_ATTRIBUTES ,FILE_OPEN ,0 ,ACL_NO_MODE ); + oparms.fid = &fid; + +/* Try to open as a directory (NOT_FILE) */ + oplock =0 ; + oparms.create_options =cifs_create_options (cifs_sb, +CREATE_NOT_FILE |OPEN_REPARSE_POINT ); + open_rc = tcon->ses->server->ops->open (xid, &oparms, &oplock,NULL ); +if (open_rc ==0 ) { +/* Successful open means that the target path is definitely a directory. */ + *directory = true; + tcon->ses->server->ops->close (xid, tcon, &fid); + }else if (open_rc == -ENOTDIR ) { +/* -ENOTDIR means that the target path is definitely a file. */ + *directory = false; + }else if (open_rc == -ENOENT ) { +/* -ENOENT means that the target path does not exist. */ +cifs_dbg (FYI , +"%s: symlink target path '%s' does not exist, " +"creating '%s' as file symlink\n" , + __func__, symname, full_path); + }else { +/* Try to open as a file (NOT_DIR) */ + oplock =0 ; + oparms.create_options =cifs_create_options (cifs_sb, +CREATE_NOT_DIR |OPEN_REPARSE_POINT ); + open_rc = tcon->ses->server->ops->open (xid, &oparms, &oplock,NULL ); +if (open_rc ==0 ) { +/* Successful open means that the target path is definitely a file. */ + *directory = false; + tcon->ses->server->ops->close (xid, tcon, &fid); + }else if (open_rc == -EISDIR ) { +/* -EISDIR means that the target path is definitely a directory. */ + *directory = true; + }else { +/* +* This code branch is called when we do not have a permission to +* open the resolved_path or some other client/process denied +* opening the resolved_path. +* +* TODO: Try to use ops->query_dir_first on the parent directory +* of resolved_path, search for basename of resolved_path and +* check if the ATTR_DIRECTORY is set in fi.Attributes. In some +* case this could work also when opening of the path is denied. +*/ +cifs_dbg (FYI , +"%s: cannot determinate if the symlink target path '%s' " +"is directory or not, creating '%s' as file symlink\n" , + __func__, symname, full_path); + } + } + +kfree (resolved_path); +cifs_put_tlink (tlink); +return 0 ; +} +static int nfs_set_reparse_buf (struct reparse_posix_data *buf,mode_t mode,dev_t dev,struct kvec *iov)
@@ -137,7 +295,7 @@ static int mknod_nfs(unsigned int xid, struct inode *inode, }; new =smb2_get_reparse_inode (&data, inode->i_sb, xid, - tcon, full_path, &iov,NULL ); + tcon, full_path, false, &iov,NULL );if (!IS_ERR (new))d_instantiate (dentry, new);else
@@ -283,7 +441,7 @@ static int mknod_wsl(unsigned int xid, struct inode *inode, data.wsl.eas_len = len; new =smb2_get_reparse_inode (&data, inode->i_sb, - xid, tcon, full_path, + xid, tcon, full_path, false, &reparse_iov, &xattr_iov);if (!IS_ERR (new))d_instantiate (dentry, new);
fs/smb/client/smb2inode.c +2 -1
@@ -1198,6 +1198,7 @@ struct inode *smb2_get_reparse_inode(struct cifs_open_info_data *data,const unsigned int xid, struct cifs_tcon *tcon, const char *full_path, + bool directory, struct kvec *reparse_iov, struct kvec *xattr_iov) {
@@ -1217,7 +1218,7 @@ struct inode *smb2_get_reparse_inode(struct cifs_open_info_data *data,FILE_READ_ATTRIBUTES |FILE_WRITE_ATTRIBUTES ,FILE_CREATE , -CREATE_NOT_DIR |OPEN_REPARSE_POINT , + (directory ?CREATE_NOT_FILE :CREATE_NOT_DIR ) |OPEN_REPARSE_POINT , ACL_NO_MODE);if (xattr_iov) oparms.ea_cctx = xattr_iov;
fs/smb/client/smb2proto.h +1 -0
@@ -61,6 +61,7 @@ struct inode *smb2_get_reparse_inode(struct cifs_open_info_data *data,const unsigned int xid, struct cifs_tcon *tcon, const char *full_path, + bool directory, struct kvec *reparse_iov, struct kvec *xattr_iov); int smb2_query_reparse_point(const unsigned int xid,
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 12/17 cifs: Fix creating native symlinks pointing to current or parent directory
In reply to Sasha LevinFrom: Pali Rohár <[email protected]>
[ Upstream commit 63271b7d569fbe924bccc7dadc17d3d07a4e5f7a ]
Calling 'ln -s . symlink' or 'ln -s .. symlink' creates symlink pointing to some object name which ends with U+F029 unicode codepoint. This is because trailing dot in the object name is replaced by non-ASCII unicode codepoint.
So Linux SMB client currently is not able to create native symlink pointing to current or parent directory on Windows SMB server which can be read by either on local Windows server or by any other SMB client which does not implement compatible-reverse character replacement.
Fix this problem in cifsConvertToUTF16() function which is doing that character replacement. Function comment already says that it does not need to handle special cases '.' and '..', but after introduction of native symlinks in reparse point form, this handling is needed.
Note that this change depends on the previous change "cifs: Improve creating native symlinks pointing to directory".
--- fs/smb/client/cifs_unicode.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
fs/smb/client/cifs_unicode.c +14 -3
@@ -484,10 +484,21 @@ cifsConvertToUTF16(__le16 *target, const char *source, int srclen,/** * Remap spaces and periods found at the end of every * component of the path. The special cases of '.' and -* '..' do not need to be dealt with explicitly because -* they are addressed in namei.c:link_path_walk(). +* '..' are need to be handled because of symlinks. +* They are treated as non-end-of-string to avoid +* remapping and breaking symlinks pointing to . or .. **/ -if ((i == srclen -1 ) || (source[i+1 ] =='\\' )) +if ((i ==0 || source[i-1 ] =='\\' ) && + source[i] =='.' && + (i == srclen-1 || source[i+1 ] =='\\' )) + end_of_string = false;/* "." case */ +else if (i >=1 && + (i ==1 || source[i-2 ] =='\\' ) && + source[i-1 ] =='.' && + source[i] =='.' && + (i == srclen-1 || source[i+1 ] =='\\' )) + end_of_string = false;/* ".." case */ +else if ((i == srclen -1 ) || (source[i+1 ] =='\\' )) end_of_string = true;else end_of_string = false;
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 13/17 thermal: intel: int340x: processor: Remove MMIO RAPL CPU hotplug support
In reply to Sasha LevinFrom: Zhang Rui <[email protected]>
[ Upstream commit bfc6819e4bf56a55df6178f93241b5845ad672eb ]
CPU0/package0 is always online and the MMIO RAPL driver runs on single package systems only, so there is no need to handle CPU hotplug in it.
Always register a RAPL package device for package 0 and remove the unnecessary CPU hotplug support.
--- .../int340x_thermal/processor_thermal_rapl.c | 66 +++++++------------ 1 file changed, 22 insertions(+), 44 deletions(-)
drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c +22 -44
@@ -19,42 +19,6 @@ static const struct rapl_mmio_regs rapl_mmio_default = { .limits[RAPL_DOMAIN_DRAM] = BIT(POWER_LIMIT2), }; -static int rapl_mmio_cpu_online (unsigned int cpu) -{ -struct rapl_package *rp; - -/* mmio rapl supports package 0 only for now */ -if (topology_physical_package_id (cpu)) -return 0 ; - - rp =rapl_find_package_domain_cpuslocked (cpu, &rapl_mmio_priv, true); -if (!rp) { - rp =rapl_add_package_cpuslocked (cpu, &rapl_mmio_priv, true); -if (IS_ERR (rp)) -return PTR_ERR (rp); - } -cpumask_set_cpu (cpu, &rp->cpumask); -return 0 ; -} - -static int rapl_mmio_cpu_down_prep (unsigned int cpu) -{ -struct rapl_package *rp; -int lead_cpu; - - rp =rapl_find_package_domain_cpuslocked (cpu, &rapl_mmio_priv, true); -if (!rp) -return 0 ; - -cpumask_clear_cpu (cpu, &rp->cpumask); - lead_cpu =cpumask_first (&rp->cpumask); -if (lead_cpu >= nr_cpu_ids) -rapl_remove_package_cpuslocked (rp); -else if (rp->lead_cpu == cpu) - rp->lead_cpu = lead_cpu; -return 0 ; -} -static int rapl_mmio_read_raw (int cpu,struct reg_action *ra) {if (!ra->reg.mmio)
@@ -82,6 +46,7 @@ static int rapl_mmio_write_raw(int cpu, struct reg_action *ra)int proc_thermal_rapl_add (struct pci_dev *pdev,struct proc_thermal_device *proc_priv) {const struct rapl_mmio_regs *rapl_regs = &rapl_mmio_default; +struct rapl_package *rp;enum rapl_domain_reg_id reg;enum rapl_domain_type domain;int ret;
@@ -109,25 +74,38 @@ int proc_thermal_rapl_add(struct pci_dev *pdev, struct proc_thermal_device *procreturn PTR_ERR (rapl_mmio_priv.control_type); } - ret =cpuhp_setup_state (CPUHP_AP_ONLINE_DYN ,"powercap/rapl:online" , - rapl_mmio_cpu_online, rapl_mmio_cpu_down_prep); -if (ret <0 ) { -powercap_unregister_control_type (rapl_mmio_priv.control_type); - rapl_mmio_priv.control_type =NULL ; -return ret; +/* Register a RAPL package device for package 0 which is always online */ + rp =rapl_find_package_domain (0 , &rapl_mmio_priv, false); +if (rp) { + ret = -EEXIST ; + goto err; + } + + rp =rapl_add_package (0 , &rapl_mmio_priv, false); +if (IS_ERR (rp)) { + ret =PTR_ERR (rp); + goto err; } - rapl_mmio_priv.pcap_rapl_online = ret;return 0 ; + +err: +powercap_unregister_control_type (rapl_mmio_priv.control_type); + rapl_mmio_priv.control_type =NULL ; +return ret; }EXPORT_SYMBOL_GPL (proc_thermal_rapl_add);void proc_thermal_rapl_remove (void ) { +struct rapl_package *rp; +if (IS_ERR_OR_NULL (rapl_mmio_priv.control_type))return ; -cpuhp_remove_state (rapl_mmio_priv.pcap_rapl_online); + rp =rapl_find_package_domain (0 , &rapl_mmio_priv, false); +if (rp) +rapl_remove_package (rp);powercap_unregister_control_type (rapl_mmio_priv.control_type); }EXPORT_SYMBOL_GPL (proc_thermal_rapl_remove);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 14/17 thermal: intel: int340x: processor: Add MMIO RAPL PL4 support
In reply to Sasha LevinFrom: Zhang Rui <[email protected]>
[ Upstream commit 3fb0eea8a1c4be5884e0731ea76cbd3ce126e1f3 ]
Similar to the MSR RAPL interface, MMIO RAPL supports PL4 too, so add MMIO RAPL PL4d support to the processor_thermal driver.
As a result, the powercap sysfs for MMIO RAPL will show a new "peak power" constraint.
--- .../thermal/intel/int340x_thermal/processor_thermal_rapl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/thermal/intel/int340x_thermal/processor_thermal_rapl.c +2 -2
@@ -13,9 +13,9 @@ static struct rapl_if_priv rapl_mmio_priv;static const struct rapl_mmio_regs rapl_mmio_default = { .reg_unit =0x5938 , - .regs[RAPL_DOMAIN_PACKAGE ] = {0x59a0 ,0x593c ,0x58f0 ,0 ,0x5930 }, + .regs[RAPL_DOMAIN_PACKAGE ] = {0x59a0 ,0x593c ,0x58f0 ,0 ,0x5930 ,0x59b0 }, .regs[RAPL_DOMAIN_DRAM ] = {0x58e0 ,0x58e8 ,0x58ec ,0 ,0 }, - .limits[RAPL_DOMAIN_PACKAGE ] =BIT (POWER_LIMIT2 ), + .limits[RAPL_DOMAIN_PACKAGE ] =BIT (POWER_LIMIT2 ) |BIT (POWER_LIMIT4 ), .limits[RAPL_DOMAIN_DRAM ] =BIT (POWER_LIMIT2 ), };
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 15/17 net: amd: mvme147: Fix probe banner message
In reply to Sasha LevinFrom: Daniel Palmer <[email protected]>
[ Upstream commit 82c5b53140faf89c31ea2b3a0985a2f291694169 ]
Currently this driver prints this line with what looks like a rogue format specifier when the device is probed:
[ 2.840000] eth%d: MVME147 at 0xfffe1800, irq 12, Hardware Address xx:xx:xx:xx:xx:xx
Change the printk() for netdev_info() and move it after the registration has completed so it prints out the name of the interface properly.
--- drivers/net/ethernet/amd/mvme147.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/ethernet/amd/mvme147.c +3 -4
@@ -105,10 +105,6 @@ static struct net_device * __init mvme147lance_probe(void) macaddr[3 ] = address&0xff ;eth_hw_addr_set (dev, macaddr); -printk ("%s: MVME147 at 0x%08lx, irq %d, Hardware Address %pM\n" , - dev->name, dev->base_addr,MVME147_LANCE_IRQ , - dev->dev_addr); - lp =netdev_priv (dev); lp->ram =__get_dma_pages (GFP_ATOMIC ,3 );/* 32K */ if (!lp->ram) {
@@ -138,6 +134,9 @@ static struct net_device * __init mvme147lance_probe(void)return ERR_PTR (err); } +netdev_info (dev,"MVME147 at 0x%08lx, irq %d, Hardware Address %pM\n" , + dev->base_addr,MVME147_LANCE_IRQ , dev->dev_addr); +return dev; }
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 16/17 NFS: remove revoked delegation from server's delegation list
In reply to Sasha LevinFrom: Dai Ngo <[email protected]>
[ Upstream commit 7ef60108069b7e3cc66432304e1dd197d5c0a9b5 ]
After the delegation is returned to the NFS server remove it from the server's delegations list to reduce the time it takes to scan this list.
Network trace captured while running the below script shows the time taken to service the CB_RECALL increases gradually due to the overhead of traversing the delegation list in nfs_delegation_find_inode_server.
The NFS server in this test is a Solaris server which issues CB_RECALL when receiving the all-zero stateid in the SETATTR.
mount=/mnt/data
for i in $(seq 1 20)
do
echo $i
mkdir $mount/testtarfile$i
time tar -C $mount/testtarfile$i -xf 5000_files.tar
done
--- fs/nfs/delegation.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/nfs/delegation.c +5 -0
@@ -981,6 +981,11 @@ void nfs_delegation_mark_returned(struct inode *inode, }nfs_mark_delegation_revoked (delegation); +clear_bit (NFS_DELEGATION_RETURNING , &delegation->flags); +spin_unlock (&delegation->lock); +if (nfs_detach_delegation (NFS_I (inode), delegation,NFS_SERVER (inode))) +nfs_put_delegation (delegation); + goto out_rcu_unlock; out_clear_returning:clear_bit (NFS_DELEGATION_RETURNING , &delegation->flags);
Signature · 1 line
2.43.0
Sasha Levin
maintainerPATCH 17/17 misc: sgi-gru: Don't disable preemption in GRU driver
In reply to Sasha LevinFrom: Dimitri Sivanich <[email protected]>
[ Upstream commit b983b271662bd6104d429b0fd97af3333ba760bf ]
Disabling preemption in the GRU driver is unnecessary, and clashes with sleeping locks in several code paths. Remove preempt_disable and preempt_enable from the GRU driver.
--- drivers/misc/sgi-gru/grukservices.c | 2 -- drivers/misc/sgi-gru/grumain.c | 4 ---- drivers/misc/sgi-gru/grutlbpurge.c | 2 -- 3 files changed, 8 deletions(-)
drivers/misc/sgi-gru/grukservices.c +0 -2
@@ -258,7 +258,6 @@ static int gru_get_cpu_resources(int dsr_bytes, void **cb, void **dsr)int lcpu;BUG_ON (dsr_bytes >GRU_NUM_KERNEL_DSR_BYTES ); -preempt_disable (); bs =gru_lock_kernel_context (-1 ); lcpu =uv_blade_processor_id (); *cb = bs->kernel_cb + lcpu *GRU_HANDLE_STRIDE ;
@@ -272,7 +271,6 @@ static int gru_get_cpu_resources(int dsr_bytes, void **cb, void **dsr)static void gru_free_cpu_resources (void *cb,void *dsr) {gru_unlock_kernel_context (uv_numa_blade_id ()); -preempt_enable (); }/*
drivers/misc/sgi-gru/grumain.c +0 -4
@@ -941,10 +941,8 @@ vm_fault_t gru_fault(struct vm_fault *vmf) again:mutex_lock (>s->ts_ctxlock); -preempt_disable ();if (gru_check_context_placement (gts)) { -preempt_enable ();mutex_unlock (>s->ts_ctxlock);gru_unload_context (gts,1 );return VM_FAULT_NOPAGE ;
@@ -953,7 +951,6 @@ vm_fault_t gru_fault(struct vm_fault *vmf)if (!gts->ts_gru) {STAT (load_user_context);if (!gru_assign_gru_context (gts)) { -preempt_enable ();mutex_unlock (>s->ts_ctxlock);set_current_state (TASK_INTERRUPTIBLE );schedule_timeout (GRU_ASSIGN_DELAY );/* true hack ZZZ */
@@ -969,7 +966,6 @@ vm_fault_t gru_fault(struct vm_fault *vmf) vma->vm_page_prot); } -preempt_enable ();mutex_unlock (>s->ts_ctxlock);return VM_FAULT_NOPAGE ;
drivers/misc/sgi-gru/grutlbpurge.c +0 -2
@@ -65,7 +65,6 @@ static struct gru_tlb_global_handle *get_lock_tgh_handle(struct gru_statestruct gru_tlb_global_handle *tgh;int n; -preempt_disable ();if (uv_numa_blade_id () == gru->gs_blade_id) n =get_on_blade_tgh (gru);else
@@ -79,7 +78,6 @@ static struct gru_tlb_global_handle *get_lock_tgh_handle(struct gru_statestatic void get_unlock_tgh_handle (struct gru_tlb_global_handle *tgh) {unlock_tgh_handle (tgh); -preempt_enable (); }/*
Signature · 1 line
2.43.0